If we were using a German datacentre we would need to turn “.blob.core.windows.net” into “.blob.core.cloudapi.de”. This means that a template or a script is only valid for one kind of cloud and we would need to modify both if we want to use them on another cloud.
Fortunately, there is another way to do this making our codes valid everywhere. I’m going to show you some examples of how we would get the uri both on an Azure template and a PowerShell script.
"storageUri": "[concat(reference(resourceId('Microsoft.Storage/storageAccounts/', variables('StorageAccountName'))).primaryEndpoints.blob)]"
$storageUri = “http://” + $StorageAccountName + “.blob.core.windows.net”
$storageUri = (Get-AzureRmStorageAccount -Name $StorageAccountName -ResourceGroupName $ResourceGroupName).PrimaryEndpoints.Blob
We will get and uri like this one: “https://StorageAccountName.blob.core.cloudapi.de/” This way we make our codes valid everywhere for both templates and scripts.
Furthermore, notice that “primaryEndpoints” is our key here and that we have these other functions available: PrimaryEndpoints.File, PrimaryEndpoints.Queue and PrimaryEndpoints.Table. These will retrieve the “file.core”, “queue.core” and “table.core” uri’s if we need them.