Skip to content

Instantly share code, notes, and snippets.

@wgv-zbonham
Created May 27, 2015 16:15
Show Gist options
  • Save wgv-zbonham/78807996437c048d3d59 to your computer and use it in GitHub Desktop.
Save wgv-zbonham/78807996437c048d3d59 to your computer and use it in GitHub Desktop.
Storage Context for Non Default Azure Environments
<#
We only get Azure commercial and Azure China by default but this seems to work for Azure Gov by specifying the -Endpoint parameter
#>
$storageKey = [System.Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes("My really long key that came from somewhere else and why isn't there a get-base64string cmdlet already??"))
$context = New-AzureStorageContext -StorageAccountName "Testing" -StorageAccountKey $storageKey -Endpoint "core.usgovcloudapp.net"
$context
StorageAccountName : Testing
BlobEndPoint : https://testing.blob.core.usgovcloudapp.net/
TableEndPoint : https://testing.table.core.usgovcloudapp.net/
QueueEndPoint : https://testing.queue.core.usgovcloudapp.net/
Context : Microsoft.WindowsAzure.Commands.Common.Storage.AzureStorageContext
Name :
StorageAccount : BlobEndpoint=https://testing.blob.core.usgovcloudapp.net/;QueueEndpoint=https://testing.queue.core
.usgovcloudapp.net/;TableEndpoint=https://testing.table.core.usgovcloudapp.net/;FileEndpoint=https
://testing.file.core.usgovcloudapp.net/;AccountName=Testing;AccountKey=[key hidden]
EndPointSuffix : core.usgovcloudapp.net/
@waynenus
Copy link

waynenus commented Sep 7, 2018

Try add the following cmd with New-AzureStorageContext
-Endpoint core.chinacloudapi.cn

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment