X
Closing this message and/or accessing our website tells us you are happy to receive all cookies on the ClearPeople website.
However, if you would like to, you can change your cookies settings at any time.
Some of you will already know about new cloud locations that Azure is creating. Because of this, new uri’s are there, so a new way of getting them is being used now.
Working on Azure Templates or PowerShell, when we need to reference, in example, a blob of a storage account, we usually type this: “http://’StorageAccountName’.blob.core.windows.net".

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.


Azure Template:


Old way: 


"storageUri": [concat('http://',variables('StorageAccountName'),'.blob.core.windows.net')]"

New way:

"storageUri": "[concat(reference(resourceId('Microsoft.Storage/storageAccounts/', variables('StorageAccountName'))).primaryEndpoints.blob)]"


PowerShell script:


Old way:

$storageUri = “http://”  + $StorageAccountName + “.blob.core.windows.net”


New way:

$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.

Author bio

Ivan Chesa
Ivan Chesa
Junior Developer
I’m part of the SharePoint development team. Besides working on client and internal projects, I enjoy learning more about other technologies like Azure. In my spare time I love playing video games with friends and I also like to watch TV shows.

Comments


comments powered by Disqus

Related Articles

Sign up to our Newsletter

Every now and then, we'd like to send you information that delivers, develops and promotes our products and services that are relevant to you. Submitting your details tells us that you're OK with this and you also agree to our Privacy & Cookies policy. You can, of course, opt out of these communications at any time.