Azure Government Storage Accounts are generated with the incorrect URI
Describe the bug
When connecting to an Azure Storage account using Get-AzTableTable, the returned [Microsoft.Azure.Cosmos.Table.CloudTable] object appears to have the commercial endpoints hardcoded instead of the proper USGov endpoints.
Error Message
MethodInvocationException: Exception calling "Execute" with "1" argument(s): "No such host is known.
(storageaccount.table.core.windows.net:443)"
PowerShell Version Include here the full output of the following command line:
Name Value
---- -----
PSVersion 7.3.2
PSEdition Core
GitCommitId 7.3.2
OS Microsoft Windows 10.0.22621
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
Complete list of Azure related Powershell modules
ModuleType Version PreRelease Name PSEdition ExportedCommands
---------- ------- ---------- ---- --------- ----------------
Script 5.1.2 Azure Desk {Get-AzureAutomationCertificate, Get-AzureAutomationConnection, New-AzureAutomationConnection, Remove-AzureAutomationConnection…}
Manifest 0.5.0 Azure.AnalysisServices Desk {Add-AzureAnalysisServicesAccount, Restart-AzureAnalysisServicesInstance, Export-AzureAnalysisServicesInstanceLog, Sync-AzureAnalysisServicesInstance}
Script 4.2.1 Azure.Storage Desk {Get-AzureStorageTable, New-AzureStorageTableSASToken, New-AzureStorageTableStoredAccessPolicy, New-AzureStorageTable…}
Script 5.7.0 AzureRM Desk
Script 0.6.6 AzureRM.AnalysisServices Desk {Resume-AzureRmAnalysisServicesServer, Suspend-AzureRmAnalysisServicesServer, Get-AzureRmAnalysisServicesServer, Remove-AzureRmAnalysisServicesServer…}
Script 5.1.2 AzureRM.ApiManagement Desk {Add-AzureRmApiManagementRegion, Get-AzureRmApiManagementSsoToken, New-AzureRmApiManagementHostnameConfiguration, New-AzureRmApiManagementRegion…}
Script 0.1.3 AzureRM.ApplicationInsights Desk {Get-AzureRmApplicationInsights, New-AzureRmApplicationInsights, Remove-AzureRmApplicationInsights, Set-AzureRmApplicationInsightsPricingPlan…}
Script 4.3.2 AzureRM.Automation Desk {Get-AzureRMAutomationHybridWorkerGroup, Get-AzureRmAutomationJobOutputRecord, Import-AzureRmAutomationDscNodeConfiguration, Export-AzureRmAutomationDscConfiguration…}
Script 4.0.4 AzureRM.Backup Desk {Backup-AzureRmBackupItem, Enable-AzureRmBackupContainerReregistration, Get-AzureRmBackupContainer, Register-AzureRmBackupContainer…}
Script 4.0.6 AzureRM.Batch Desk {Remove-AzureRmBatchAccount, Get-AzureRmBatchAccount, Get-AzureRmBatchAccountKeys, New-AzureRmBatchAccount…}
Script 0.14.1 AzureRM.Billing Desk {Get-AzureRmBillingInvoice, Get-AzureRmBillingPeriod, Get-AzureRmEnrollmentAccount}
Script 4.2.2 AzureRM.Cdn Desk {Get-AzureRmCdnProfile, Get-AzureRmCdnProfileSsoUrl, New-AzureRmCdnProfile, Remove-AzureRmCdnProfile…}
Script 0.9.4 AzureRM.CognitiveServices Desk {Get-AzureRmCognitiveServicesAccount, Get-AzureRmCognitiveServicesAccountKey, Get-AzureRmCognitiveServicesAccountSkus, Get-AzureRmCognitiveServicesAccountUsage…}
Script 4.6.0 AzureRM.Compute Desk {Remove-AzureRmAvailabilitySet, Get-AzureRmAvailabilitySet, New-AzureRmAvailabilitySet, Update-AzureRmAvailabilitySet…}
Script 0.3.1 AzureRM.Consumption Desk Get-AzureRmConsumptionUsageDetail
Script 0.2.5 AzureRM.ContainerInstance Desk {New-AzureRmContainerGroup, Get-AzureRmContainerGroup, Remove-AzureRmContainerGroup, Get-AzureRmContainerInstanceLog}
Script 1.0.4 AzureRM.ContainerRegistry Desk {New-AzureRmContainerRegistry, Get-AzureRmContainerRegistry, Update-AzureRmContainerRegistry, Remove-AzureRmContainerRegistry…}
Script 4.2.2 AzureRM.DataFactories Desk {Remove-AzureRmDataFactory, Get-AzureRmDataFactoryRun, Get-AzureRmDataFactorySlice, Save-AzureRmDataFactoryLog…}
Script 0.5.3 AzureRM.DataFactoryV2 Desk {Set-AzureRmDataFactoryV2, Update-AzureRmDataFactoryV2, Get-AzureRmDataFactoryV2, Remove-AzureRmDataFactoryV2…}
Script 4.2.3 AzureRM.DataLakeAnalytics Desk {Get-AzureRmDataLakeAnalyticsDataSource, New-AzureRmDataLakeAnalyticsCatalogCredential, Remove-AzureRmDataLakeAnalyticsCatalogCredential, Remove-AzureRmDataLakeAnalyticsCatalogSecret…}
Script 5.2.0 AzureRM.DataLakeStore Desk {Get-AzureRmDataLakeStoreTrustedIdProvider, Remove-AzureRmDataLakeStoreTrustedIdProvider, Remove-AzureRmDataLakeStoreFirewallRule, Set-AzureRmDataLakeStoreTrustedIdProvider…}
Script 4.0.4 AzureRM.DevTestLabs Desk {Get-AzureRmDtlAllowedVMSizesPolicy, Get-AzureRmDtlAutoShutdownPolicy, Get-AzureRmDtlAutoStartPolicy, Get-AzureRmDtlVMsPerLabPolicy…}
Script 4.1.2 AzureRM.Dns Desk {Get-AzureRmDnsRecordSet, New-AzureRmDnsRecordConfig, Remove-AzureRmDnsRecordSet, Set-AzureRmDnsRecordSet…}
Script 0.3.2 AzureRM.EventGrid Desk {New-AzureRmEventGridTopic, Get-AzureRmEventGridTopic, Set-AzureRmEventGridTopic, New-AzureRmEventGridTopicKey…}
Script 0.6.3 AzureRM.EventHub Desk {New-AzureRmEventHubNamespace, Get-AzureRmEventHubNamespace, Set-AzureRmEventHubNamespace, Remove-AzureRmEventHubNamespace…}
Script 4.1.2 AzureRM.HDInsight Desk {Get-AzureRmHDInsightJob, New-AzureRmHDInsightSqoopJobDefinition, Wait-AzureRmHDInsightJob, New-AzureRmHDInsightStreamingMapReduceJobDefinition…}
Script 4.0.4 AzureRM.Insights Desk {Get-AzureRmMetricDefinition, Get-AzureRmMetric, Remove-AzureRmLogProfile, Get-AzureRmLogProfile…}
Script 3.1.2 AzureRM.IotHub Desk {Add-AzureRmIotHubKey, Get-AzureRmIotHubEventHubConsumerGroup, Get-AzureRmIotHubConnectionString, Get-AzureRmIotHubJob…}
Script 4.3.0 AzureRM.KeyVault Desk {Add-AzureKeyVaultCertificate, Set-AzureKeyVaultCertificateAttribute, Stop-AzureKeyVaultCertificateOperation, Get-AzureKeyVaultCertificateOperation…}
Script 4.0.3 AzureRM.LogicApp Desk {Get-AzureRmIntegrationAccountAgreement, Get-AzureRmIntegrationAccountCallbackUrl, Get-AzureRmIntegrationAccountCertificate, Get-AzureRmIntegrationAccount…}
Script 0.17.2 AzureRM.MachineLearning Desk {Move-AzureRmMlCommitmentAssociation, Get-AzureRmMlCommitmentAssociation, Get-AzureRmMlCommitmentPlanUsageHistory, Remove-AzureRmMlCommitmentPlan…}
Script 0.4.2 AzureRM.MachineLearningCompute Desk {Get-AzureRmMlOpCluster, Get-AzureRmMlOpClusterKey, Test-AzureRmMlOpClusterSystemServicesUpdateAvailability, Update-AzureRmMlOpClusterSystemService…}
Script 0.2.1 AzureRM.MarketplaceOrdering Desk {Get-AzureRmMarketplaceTerms, Set-AzureRmMarketplaceTerms}
Script 0.9.2 AzureRM.Media Desk {Sync-AzureRmMediaServiceStorageKeys, Set-AzureRmMediaServiceKey, Get-AzureRmMediaServiceKeys, Get-AzureRmMediaServiceNameAvailability…}
Script 5.4.2 AzureRM.Network Desk {Add-AzureRmApplicationGatewayAuthenticationCertificate, Get-AzureRmApplicationGatewayAuthenticationCertificate, New-AzureRmApplicationGatewayAuthenticationCertificate, Remove-AzureRmApplic…
Script 4.1.1 AzureRM.NotificationHubs Desk {Get-AzureRmNotificationHub, Get-AzureRmNotificationHubAuthorizationRules, Get-AzureRmNotificationHubListKeys, Get-AzureRmNotificationHubPNSCredentials…}
Script 4.3.2 AzureRM.OperationalInsights Desk {New-AzureRmOperationalInsightsAzureActivityLogDataSource, New-AzureRmOperationalInsightsCustomLogDataSource, Disable-AzureRmOperationalInsightsLinuxCustomLogCollection, Disable-AzureRmOper…
Script 4.1.4 AzureRM.PowerBIEmbedded Desk {Remove-AzureRmPowerBIWorkspaceCollection, Get-AzureRmPowerBIWorkspaceCollection, Get-AzureRmPowerBIWorkspaceCollectionAccessKeys, Get-AzureRmPowerBIWorkspace…}
Script 4.6.0 AzureRM.Profile Desk {Disable-AzureRmDataCollection, Disable-AzureRmContextAutosave, Enable-AzureRmDataCollection, Enable-AzureRmContextAutosave…}
Script 4.1.2 AzureRM.RecoveryServices Desk {Get-AzureRmRecoveryServicesBackupProperty, Get-AzureRmRecoveryServicesVault, Get-AzureRmRecoveryServicesVaultSettingsFile, New-AzureRmRecoveryServicesVault…}
Script 4.1.2 AzureRM.RecoveryServices.Backup Desk {Backup-AzureRmRecoveryServicesBackupItem, Get-AzureRmRecoveryServicesBackupManagementServer, Get-AzureRmRecoveryServicesBackupContainer, Unregister-AzureRmRecoveryServicesBackupContainer…}
Script 0.2.4 AzureRM.RecoveryServices.SiteRecov… Desk {Edit-AzureRmRecoveryServicesAsrRecoveryPlan, Get-AzureRmRecoveryServicesAsrAlertSetting, Get-AzureRmRecoveryServicesAsrEvent, Get-AzureRmRecoveryServicesAsrFabric…}
Script 4.1.2 AzureRM.RedisCache Desk {Remove-AzureRmRedisCachePatchSchedule, New-AzureRmRedisCacheScheduleEntry, Get-AzureRmRedisCachePatchSchedule, New-AzureRmRedisCachePatchSchedule…}
Script 0.3.3 AzureRM.Relay Desk {New-AzureRmRelayNamespace, Get-AzureRmRelayNamespace, Set-AzureRmRelayNamespace, Remove-AzureRmRelayNamespace…}
Script 5.5.2 AzureRM.Resources Desk {Get-AzureRmProviderOperation, Remove-AzureRmRoleAssignment, Get-AzureRmRoleAssignment, New-AzureRmRoleAssignment…}
Script 0.16.3 AzureRM.Scheduler Desk {Disable-AzureRmSchedulerJobCollection, Enable-AzureRmSchedulerJobCollection, Get-AzureRmSchedulerJobCollection, Get-AzureRmSchedulerJob…}
Script 4.1.2 AzureRM.ServerManagement Desk {Invoke-AzureRmServerManagementPowerShellCommand, Get-AzureRmServerManagementSession, New-AzureRmServerManagementSession, Remove-AzureRmServerManagementSession…}
Script 0.6.4 AzureRM.ServiceBus Desk {New-AzureRmServiceBusNamespace, Get-AzureRmServiceBusNamespace, Set-AzureRmServiceBusNamespace, Remove-AzureRmServiceBusNamespace…}
Script 0.3.4 AzureRM.ServiceFabric Desk {Add-AzureRmServiceFabricApplicationCertificate, Add-AzureRmServiceFabricClientCertificate, Add-AzureRmServiceFabricClusterCertificate, Add-AzureRmServiceFabricNode…}
Script 5.0.6 AzureRM.SiteRecovery Desk {Get-AzureRmSiteRecoveryFabric, New-AzureRmSiteRecoveryFabric, Remove-AzureRmSiteRecoveryFabric, Stop-AzureRmSiteRecoveryJob…}
Script 4.4.0 AzureRM.Sql Desk {Get-AzureRmSqlDatabaseTransparentDataEncryption, Get-AzureRmSqlDatabaseTransparentDataEncryptionActivity, Set-AzureRmSqlDatabaseTransparentDataEncryption, Get-AzureRmSqlDatabaseUpgradeHint…
Script 4.2.3 AzureRM.Storage Desk {Get-AzureRmStorageAccount, Get-AzureRmStorageAccountKey, New-AzureRmStorageAccount, New-AzureRmStorageAccountKey…}
Script 4.0.4 AzureRM.StreamAnalytics Desk {Get-AzureRmStreamAnalyticsFunction, Get-AzureRmStreamAnalyticsDefaultFunctionDefinition, New-AzureRmStreamAnalyticsFunction, Remove-AzureRmStreamAnalyticsFunction…}
Script 4.0.1 AzureRM.Tags Desk {Remove-AzureRmTag, Get-AzureRmTag, New-AzureRmTag}
Script 4.0.3 AzureRM.TrafficManager Desk {Disable-AzureRmTrafficManagerEndpoint, Enable-AzureRmTrafficManagerEndpoint, Set-AzureRmTrafficManagerEndpoint, Get-AzureRmTrafficManagerEndpoint…}
Script 4.0.2 AzureRM.UsageAggregates Desk Get-UsageAggregates
Script 4.2.2 AzureRM.Websites Desk {Get-AzureRmAppServicePlan, Set-AzureRmAppServicePlan, New-AzureRmAppServicePlan, Remove-AzureRmAppServicePlan…}
Code Snippet Profile: (this is an Azure Function using a Managed Identity)
if ($env:MSI_SECRET) {
Disable-AzContextAutosave -Scope Process | Out-Null
Connect-AzAccount -Identity -Environment AzureUSGovernment
}
Script:
Select-AzSubscription -SubscriptionId $env:storageAccountSubscriptionID
$storageTable = Get-AzTableTable `
-storageAccountName $env:storageAccountName `
-resourceGroup $env:storageResourceGroupName `
-TableName 'tablename'
Generated Value
ServiceClient : Microsoft.Azure.Cosmos.Table.CloudTableClient
Name : intune
Uri : https://storageaccount.table.core.windows.net/table
StorageUri : Primary = 'https://storageaccount.table.core.windows.net/table'; Secondary = ''
Added the following code to override which seems to work:
$tableAzGov = [Microsoft.Azure.Cosmos.Table.CloudTable]::new(
"https://$($env:storageAccountName).table.core.usgovcloudapi.net", `
$storageTable.ServiceClient.Credentials
)
Generated Value
ServiceClient : Microsoft.Azure.Cosmos.Table.CloudTableClient
Name : intune
Uri : https://storageaccount.table.core.usgovcloudapi.net/table
StorageUri : Primary = 'https://storageaccount.table.core.usgovcloudapi.net/table'; Secondary = ''
More information
- OS: Windows Azure Function, replicated on Windows 11 workstation
Additional context N/A
Hi @garrett-wood / @PaulCheng - please unassign me. I do not work at Microsoft anymore.
It seems the endpoint suffix is hardcoded to be public azure cloud in AzureRmStorageTableCoreHelper.psm1. This is a bug of limitation as the ps script doesn't work with sovereign cloud.