Azure / azure-powershell

Microsoft Azure PowerShell
Other
4.25k stars 3.85k forks source link

Remove-AzStorageTable hangs for a long time and then doesn't remove the table. #24539

Closed gvanbuskirkpps closed 6 months ago

gvanbuskirkpps commented 7 months ago

Description

I've attempted this across multiple subscriptions, had my coworker try it as well.

If you check the issue script, it contains minimal code to reproduce the issue. You'll need to fill in a subscriptionname, StorageAccountName, StorageAccountResourceGroupName, and a Table name which you don't care if you delete.

The script will hang for a long time before looking like it did its work and then silently quits, without ever actually deleting the table.

I did the same logic in az cli and the portal/storage explorer ui and the tables are deleted almost instantly.

Issue script & Debug output

$SubscriptionName = ''
$StorageAccountName = ''
$StorageAccountResourceGroupName = ''
$TableName

Set-AzContext (Get-AzSubscription | ? Name -eq $SubscriptionName).Id
$key = (Get-AzStorageAccountKey -StorageAccountName $StorageAccountName -ResourceGroupName $StorageAccountResourceGroupName)[0].value
$ctx = New-AzStorageContext -StorageAccountName $StorageAccountName -StorageAccountKey $key
$table = Get-AzStorageTable -Context $ctx -Name $TableName
Remove-AzStorageTable -Table $table.name -Context $ctx -Confirm

Environment data

Name                           Value
----                           -----
PSVersion                      7.4.1
PSEdition                      Core
GitCommitId                    7.4.1
OS                             Microsoft Windows 10.0.19045
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Module versions

ModuleType Version    PreRelease Name                                PSEdition ExportedCommands
---------- -------    ---------- ----                                --------- ----------------
Script     9.1.1                 Az                                  Core,Desk
Script     2.11.2                Az.Accounts                         Core,Desk {Disable-AzDataCollection, Disable-AzCo…
Script     2.10.3                Az.Accounts                         Core,Desk {Disable-AzDataCollection, Disable-AzCo…
Script     2.0.0                 Az.Advisor                          Core,Desk {Disable-AzAdvisorRecommendation, Enabl…
Script     5.0.1                 Az.Aks                              Core,Desk {Get-AzAksCluster, New-AzAksCluster, Re…
Script     0.5.0                 Az.AlertsManagement                 Core,Desk {Get-AzAlert, Get-AzAlertObjectHistory,…
Script     1.1.4                 Az.AnalysisServices                 Core,Desk {Resume-AzAnalysisServicesServer, Suspe…
Script     4.0.1                 Az.ApiManagement                    Core,Desk {Add-AzApiManagementApiToGateway, Add-A…
Script     1.2.0                 Az.AppConfiguration                 Core,Desk {Get-AzAppConfigurationStore, Get-AzApp…
Script     2.1.0                 Az.ApplicationInsights              Core,Desk {Get-AzApplicationInsights, Get-AzAppli…
Script     2.0.0                 Az.Attestation                      Core,Desk {Get-AzAttestationPolicy, Set-AzAttesta…
Script     1.9.1                 Az.Automation                       Core,Desk {Set-AzAutomationPython3Package, New-Az…
Script     3.2.1                 Az.Batch                            Core,Desk {Remove-AzBatchAccount, Get-AzBatchAcco…
Script     2.0.0                 Az.Billing                          Core,Desk {Get-AzBillingInvoice, Get-AzBillingPer…
Script     2.1.0                 Az.Cdn                              Core,Desk {Clear-AzCdnEndpointContent, Clear-AzFr…
Script     1.1.0                 Az.CloudService                     Core,Desk {Get-AzCloudService, Get-AzCloudService…
Script     1.12.0                Az.CognitiveServices                Core,Desk {Get-AzCognitiveServicesAccount, Get-Az…
Script     5.1.1                 Az.Compute                          Core,Desk {Remove-AzAvailabilitySet, Get-AzAvaila…
Script     1.0.0                 Az.ConfidentialLedger               Core,Desk {Get-AzConfidentialLedger, New-AzConfid…
Script     3.1.0                 Az.ContainerInstance                Core,Desk {Add-AzContainerInstanceOutput, Get-AzC…
Script     3.0.0                 Az.ContainerRegistry                Core,Desk {New-AzContainerRegistry, Get-AzContain…
Script     1.8.2                 Az.CosmosDB                         Core,Desk {Get-AzCosmosDBSqlContainer, Get-AzCosm…
Script     1.1.0                 Az.DataBoxEdge                      Core,Desk {Get-AzDataBoxEdgeJob, Get-AzDataBoxEdg…
Script     1.4.0                 Az.Databricks                       Core,Desk {Get-AzDatabricksAccessConnector, Get-A…
Script     1.16.10               Az.DataFactory                      Core,Desk {Set-AzDataFactoryV2, Update-AzDataFact…
Script     1.0.2                 Az.DataLakeAnalytics                Core,Desk {Get-AzDataLakeAnalyticsDataSource, New…
Script     1.3.0                 Az.DataLakeStore                    Core,Desk {Get-AzDataLakeStoreTrustedIdProvider, …
Script     1.0.0                 Az.DataProtection                   Core,Desk {Backup-AzDataProtectionBackupInstanceA…
Script     1.0.1                 Az.DataShare                        Core,Desk {New-AzDataShareAccount, Get-AzDataShar…
Script     1.1.0                 Az.DeploymentManager                Core,Desk {Get-AzDeploymentManagerArtifactSource,…
Script     3.1.1                 Az.DesktopVirtualization            Core,Desk {Disconnect-AzWvdUserSession, Expand-Az…
Script     1.0.2                 Az.DevTestLabs                      Core,Desk {Get-AzDtlAllowedVMSizesPolicy, Get-AzD…
Script     1.1.2                 Az.Dns                              Core,Desk {Get-AzDnsRecordSet, New-AzDnsRecordCon…
Script     1.5.0                 Az.EventGrid                        Core,Desk {New-AzEventGridTopic, Get-AzEventGridT…
Script     3.1.0                 Az.EventHub                         Core,Desk {New-AzEventHubNamespace, Get-AzEventHu…
Script     1.9.0                 Az.FrontDoor                        Core,Desk {New-AzFrontDoor, Get-AzFrontDoor, Set-…
Script     4.0.6                 Az.Functions                        Core,Desk {Get-AzFunctionApp, Get-AzFunctionAppAv…
Script     5.0.1                 Az.HDInsight                        Core,Desk {Get-AzHDInsightJob, New-AzHDInsightSqo…
Script     2.0.0                 Az.HealthcareApis                   Core,Desk {Get-AzHealthcareApisService, Get-AzHea…
Script     2.7.4                 Az.IotHub                           Core,Desk {Add-AzIotHubKey, Get-AzIotHubEventHubC…
Script     4.9.0                 Az.KeyVault                         Core,Desk {Add-AzKeyVaultCertificate, Update-AzKe…
Script     2.1.0                 Az.Kusto                            Core,Desk {Add-AzKustoClusterLanguageExtension, A…
Script     1.5.0                 Az.LogicApp                         Core,Desk {Get-AzIntegrationAccountAgreement, Get…
Script     1.1.3                 Az.MachineLearning                  Core,Desk {Move-AzMlCommitmentAssociation, Get-Az…
Script     1.2.1                 Az.Maintenance                      Core,Desk {Get-AzApplyUpdate, Get-AzConfiguration…
Script     1.1.0                 Az.ManagedServiceIdentity           Core,Desk {Get-AzFederatedIdentityCredentials, Ge…
Script     3.0.0                 Az.ManagedServices                  Core,Desk {Get-AzManagedServicesAssignment, Get-A…
Script     2.0.0                 Az.MarketplaceOrdering              Core,Desk {Get-AzMarketplaceTerms, Invoke-AzMarke…
Script     1.1.1                 Az.Media                            Core,Desk {Sync-AzMediaServiceStorageKey, Set-AzM…
Script     2.1.0                 Az.Migrate                          Core,Desk {Get-AzMigrateDiscoveredServer, Get-AzM…
Script     4.2.1                 Az.Monitor                          Core,Desk {Get-AzMetricDefinition, Get-AzMetric, …
Script     0.1.0                 Az.MonitoringSolutions              Core,Desk {Get-AzMonitorLogAnalyticsSolution, New…
Script     1.1.0                 Az.MySql                            Core,Desk {Get-AzMySqlConfiguration, Get-AzMySqlC…
Script     5.1.2                 Az.Network                          Core,Desk {Add-AzApplicationGatewayAuthentication…
Script     1.1.1                 Az.NotificationHubs                 Core,Desk {Get-AzNotificationHub, Get-AzNotificat…
Script     3.2.0                 Az.OperationalInsights              Core,Desk {New-AzOperationalInsightsAzureActivity…
Script     1.5.1                 Az.PolicyInsights                   Core,Desk {Get-AzPolicyEvent, Get-AzPolicyState, …
Script     1.1.0                 Az.PostgreSql                       Core,Desk {Get-AzPostgreSqlConfiguration, Get-AzP…
Script     1.2.0                 Az.PowerBIEmbedded                  Core,Desk {Remove-AzPowerBIWorkspaceCollection, G…
Script     1.0.3                 Az.PrivateDns                       Core,Desk {Get-AzPrivateDnsZone, Remove-AzPrivate…
Script     6.1.1                 Az.RecoveryServices                 Core,Desk {Get-AzRecoveryServicesBackupProperty, …
Script     1.6.0                 Az.RedisCache                       Core,Desk {Remove-AzRedisCachePatchSchedule, New-…
Script     1.1.0                 Az.RedisEnterpriseCache             Core,Desk {Export-AzRedisEnterpriseCache, Get-AzR…
Script     1.0.3                 Az.Relay                            Core,Desk {New-AzRelayNamespace, Get-AzRelayNames…
Script     0.13.0                Az.ResourceGraph                    Core,Desk {Search-AzGraph, Get-AzResourceGraphQue…
Script     1.1.0                 Az.ResourceMover                    Core,Desk {Add-AzResourceMoverMoveResource, Get-A…
Script     6.4.1                 Az.Resources                        Core,Desk {Get-AzProviderOperation, Remove-AzRole…
Script     1.3.0                 Az.Security                         Core,Desk {Get-AzSecuritySolution, Get-AzSecurity…
Script     3.0.0                 Az.SecurityInsights                 Core,Desk {Get-AzSentinelAlertRule, Get-AzSentine…
Script     2.0.0                 Az.ServiceBus                       Core,Desk {New-AzServiceBusNamespace, Get-AzServi…
Script     3.1.0                 Az.ServiceFabric                    Core,Desk {Add-AzServiceFabricClientCertificate, …
Script     1.4.1                 Az.SignalR                          Core,Desk {New-AzSignalR, Get-AzSignalR, Get-AzSi…
Script     4.1.0                 Az.Sql                              Core,Desk {Get-AzSqlDatabaseTransparentDataEncryp…
Script     1.1.0                 Az.SqlVirtualMachine                Core,Desk {New-AzSqlVM, Get-AzSqlVM, Update-AzSql…
Script     0.1.0                 Az.Ssh                              Core,Desk {Export-AzSshConfig, Enter-AzVM}
Script     1.3.2                 Az.StackHCI                         Core,Desk {Add-AzStackHCIVMAttestation, Disable-A…
Script     5.1.0                 Az.Storage                          Core,Desk {Get-AzStorageAccount, Get-AzStorageAcc…
Script     1.7.0                 Az.StorageSync                      Core,Desk {Invoke-AzStorageSyncCompatibilityCheck…
Script     2.0.0                 Az.StreamAnalytics                  Core,Desk {Get-AzStreamAnalyticsCluster, Get-AzSt…
Script     1.0.0                 Az.Support                          Core,Desk {Get-AzSupportService, Get-AzSupportPro…
Script     2.0.0                 Az.Synapse                          Core,Desk {Get-AzSynapseSparkJob, Stop-AzSynapseS…
Script     1.1.0                 Az.TrafficManager                   Core,Desk {Add-AzTrafficManagerCustomHeaderToEndp…
Script     2.11.5                Az.Websites                         Core,Desk {Get-AzAppServicePlan, Set-AzAppService…
Script     0.2.7.0               AzFilesHybrid                       Core,Desk {Get-IsElevatedSession, Assert-IsElevat…
Manifest   2.1.0                 AzTable                             Desk      {Add-AzTableRow, Get-AzTableRow, Get-Az…

    Directory: C:\Program Files\WindowsPowerShell\Modules

ModuleType Version    PreRelease Name                                PSEdition ExportedCommands
---------- -------    ---------- ----                                --------- ----------------
Script     5.1.2                 Azure                               Desk      {Get-AzureAutomationCertificate, Get-Az…
Manifest   0.5.0                 Azure.AnalysisServices              Desk      {Add-AzureAnalysisServicesAccount, Rest…
Script     4.2.1                 Azure.Storage                       Desk      {Get-AzureStorageTable, New-AzureStorag…
Binary     2.0.2.140             AzureAD                             Desk
Script     5.7.0                 AzureRM                             Desk
Script     0.6.6                 AzureRM.AnalysisServices            Desk      {Resume-AzureRmAnalysisServicesServer, …
Script     5.1.2                 AzureRM.ApiManagement               Desk      {Add-AzureRmApiManagementRegion, Get-Az…
Script     0.1.3                 AzureRM.ApplicationInsights         Desk      {Get-AzureRmApplicationInsights, New-Az…
Script     4.3.2                 AzureRM.Automation                  Desk      {Get-AzureRMAutomationHybridWorkerGroup…
Script     4.0.4                 AzureRM.Backup                      Desk      {Backup-AzureRmBackupItem, Enable-Azure…
Script     4.0.6                 AzureRM.Batch                       Desk      {Remove-AzureRmBatchAccount, Get-AzureR…
Script     0.14.1                AzureRM.Billing                     Desk      {Get-AzureRmBillingInvoice, Get-AzureRm…
Script     4.2.2                 AzureRM.Cdn                         Desk      {Get-AzureRmCdnProfile, Get-AzureRmCdnP…
Script     0.9.4                 AzureRM.CognitiveServices           Desk      {Get-AzureRmCognitiveServicesAccount, G…
Script     4.6.0                 AzureRM.Compute                     Desk      {Remove-AzureRmAvailabilitySet, Get-Azu…
Script     0.3.1                 AzureRM.Consumption                 Desk      Get-AzureRmConsumptionUsageDetail
Script     0.2.5                 AzureRM.ContainerInstance           Desk      {New-AzureRmContainerGroup, Get-AzureRm…
Script     1.0.4                 AzureRM.ContainerRegistry           Desk      {New-AzureRmContainerRegistry, Get-Azur…
Script     4.2.2                 AzureRM.DataFactories               Desk      {Remove-AzureRmDataFactory, Get-AzureRm…
Script     0.5.3                 AzureRM.DataFactoryV2               Desk      {Set-AzureRmDataFactoryV2, Update-Azure…
Script     4.2.3                 AzureRM.DataLakeAnalytics           Desk      {Get-AzureRmDataLakeAnalyticsDataSource…
Script     5.2.0                 AzureRM.DataLakeStore               Desk      {Get-AzureRmDataLakeStoreTrustedIdProvi…
Script     4.0.4                 AzureRM.DevTestLabs                 Desk      {Get-AzureRmDtlAllowedVMSizesPolicy, Ge…
Script     4.1.2                 AzureRM.Dns                         Desk      {Get-AzureRmDnsRecordSet, New-AzureRmDn…
Script     0.3.2                 AzureRM.EventGrid                   Desk      {New-AzureRmEventGridTopic, Get-AzureRm…
Script     0.6.3                 AzureRM.EventHub                    Desk      {New-AzureRmEventHubNamespace, Get-Azur…
Script     4.1.2                 AzureRM.HDInsight                   Desk      {Get-AzureRmHDInsightJob, New-AzureRmHD…
Script     4.0.4                 AzureRM.Insights                    Desk      {Get-AzureRmMetricDefinition, Get-Azure…
Script     3.1.2                 AzureRM.IotHub                      Desk      {Add-AzureRmIotHubKey, Get-AzureRmIotHu…
Script     4.3.0                 AzureRM.KeyVault                    Desk      {Add-AzureKeyVaultCertificate, Set-Azur…
Script     4.0.3                 AzureRM.LogicApp                    Desk      {Get-AzureRmIntegrationAccountAgreement…
Script     0.17.2                AzureRM.MachineLearning             Desk      {Move-AzureRmMlCommitmentAssociation, G…
Script     0.4.2                 AzureRM.MachineLearningCompute      Desk      {Get-AzureRmMlOpCluster, Get-AzureRmMlO…
Script     0.2.1                 AzureRM.MarketplaceOrdering         Desk      {Get-AzureRmMarketplaceTerms, Set-Azure…
Script     0.9.2                 AzureRM.Media                       Desk      {Sync-AzureRmMediaServiceStorageKeys, S…
Script     5.4.2                 AzureRM.Network                     Desk      {Add-AzureRmApplicationGatewayAuthentic…
Script     4.1.1                 AzureRM.NotificationHubs            Desk      {Get-AzureRmNotificationHub, Get-AzureR…
Script     4.3.2                 AzureRM.OperationalInsights         Desk      {New-AzureRmOperationalInsightsAzureAct…
Script     4.1.4                 AzureRM.PowerBIEmbedded             Desk      {Remove-AzureRmPowerBIWorkspaceCollecti…
Script     4.6.0                 AzureRM.Profile                     Desk      {Disable-AzureRmDataCollection, Disable…
Script     4.1.2                 AzureRM.RecoveryServices            Desk      {Get-AzureRmRecoveryServicesBackupPrope…
Script     4.1.2                 AzureRM.RecoveryServices.Backup     Desk      {Backup-AzureRmRecoveryServicesBackupIt…
Script     0.2.4                 AzureRM.RecoveryServices.SiteRecov… Desk      {Edit-AzureRmRecoveryServicesAsrRecover…
Script     4.1.2                 AzureRM.RedisCache                  Desk      {Remove-AzureRmRedisCachePatchSchedule,…
Script     0.3.3                 AzureRM.Relay                       Desk      {New-AzureRmRelayNamespace, Get-AzureRm…
Script     5.5.2                 AzureRM.Resources                   Desk      {Get-AzureRmProviderOperation, Remove-A…
Script     0.16.3                AzureRM.Scheduler                   Desk      {Disable-AzureRmSchedulerJobCollection,…
Script     4.1.2                 AzureRM.ServerManagement            Desk      {Invoke-AzureRmServerManagementPowerShe…
Script     0.6.4                 AzureRM.ServiceBus                  Desk      {New-AzureRmServiceBusNamespace, Get-Az…
Script     0.3.4                 AzureRM.ServiceFabric               Desk      {Add-AzureRmServiceFabricApplicationCer…
Script     5.0.6                 AzureRM.SiteRecovery                Desk      {Get-AzureRmSiteRecoveryFabric, New-Azu…
Script     4.4.0                 AzureRM.Sql                         Desk      {Get-AzureRmSqlDatabaseTransparentDataE…
Script     4.2.3                 AzureRM.Storage                     Desk      {Get-AzureRmStorageAccount, Get-AzureRm…
Script     4.0.4                 AzureRM.StreamAnalytics             Desk      {Get-AzureRmStreamAnalyticsFunction, Ge…
Script     4.0.1                 AzureRM.Tags                        Desk      {Remove-AzureRmTag, Get-AzureRmTag, New…
Script     4.0.3                 AzureRM.TrafficManager              Desk      {Disable-AzureRmTrafficManagerEndpoint,…
Script     4.0.2                 AzureRM.UsageAggregates             Desk      Get-UsageAggregates
Script     4.2.2                 AzureRM.Websites                    Desk      {Get-AzureRmAppServicePlan, Set-AzureRm…

Error output

No response

yifanz7 commented 7 months ago

@gvanbuskirkpps Could you please try Remove-AzStorageTable -Table $table.name -Context $ctx -Force instead of -Confirm to see if the issue persists? If the issue still happens, could you help check if the script hangs at Remove-AzStorageTable and get a network trace so we can investigate further? Thanks!

gvanbuskirkpps commented 7 months ago

@yifanz7 Good suggestion. I tried it with the -Force parameter instead of -Confirm and it worked fine. Issue seems to only reside with the -Confirm flag or with neither -Confirm or -Force.

yifanz7 commented 7 months ago

@gvanbuskirkpps It's great that adding -Force works! In this case -Confirm also works as intended as the differences between -Confirm and -Force are:

Also if there's content in the table, PSH will have the prompt message that needs user's input to continue the deletion if -Force is not specified.

An exmaple of deleting with -Confirm: image

Therefore for the cases of with -Confirm, and with neither -Confirm or -Force, the script would hang there waiting for user's input when the script is running unattended.

gvanbuskirkpps commented 7 months ago

@yifanz7 Did you press [Y] there? I was running it attended. When I pressed Y Enter to confirm, the cmdlet just sat there and never actually deleted the table.

yifanz7 commented 7 months ago

@gvanbuskirkpps Yeah I pressed Y and Enter to confirm and it worked well for me. Do you have a network trace of the cmdlet that hangs so that we can investigate further?

gvanbuskirkpps commented 7 months ago

@yifanz7 the eventual plan for my use case for this cmdlet is to run it unattended anyway. It's very well possible that my particular configuration is wayy out of date for this anyway. I'm running 5.1 on Az.Storage so I'm going to upgrade that and take another stab.

If I did need to reopen this issue at a later date, what kind of network trace are you looking for, just a total packet capture while I try to run the cmdlet?

yifanz7 commented 7 months ago

@gvanackern Gotcha. If running with -Force works and CLI works well too, it's unlikely to be a PSH issue. We can look into the issue further if the script doesn't work even with -Force parameter.

And for the network trace - just need http requests and responses to and from the server. Normally can get it by adding -Debug to the cmdlet. However in this case it doesn't seem to be a network issue so it might not help too much.

yifanz7 commented 6 months ago

Closing the issue for now. @gvanackern please feel free to let us know if any further assistance is needed