Azure RM - New datacentres and how to get right blob uri's

Posted 1 September 2016 12:00 AM by Ivan Chesa, Junior SharePoint Developer @ ClearPeople

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’".

If we were using a German datacentre we would need to turn “” into “”. 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'),'')]"

New way:

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

PowerShell script:

Old way:
$storageUri = “http://”  + $StorageAccountName + “”

New way:

$storageUri = (Get-AzureRmStorageAccount -Name $StorageAccountName -ResourceGroupName $ResourceGroupName).PrimaryEndpoints.Blob

We will get and uri like this one: “” 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.


Add your comment





intranet Modern SharePoint teamwork employee engagement digital workspace SharePoint JavaScript Windows Azure Digital Transformation staff satisfaction productivity Microsoft Teams Office 365 Yammer cms content management system agile GDPR Microsoft Graph collaboration Microsoft sharepoint 2016 upgrade migration SharePoint Online 2016 Tech Trends Digital Disruption Context marketing marketing SharePoint 2010 SharePoint 2013 TFS Git security kentico Analytics jquery QA Quality Assurance testing content management websites Sitecore sitecore marketplace sitecore module cloud Microsoft Cloud Storage digital strategy technical consulting sitecore modules Experience database Sitecore 7 Sitecore 8 support account management customer experience Data Storage cms integration front end front end development prototype Cloud Storage StorSimple Front-end Development Layout SharePoint 2013 colour palette UI design website design log viewer sitecore cms website Azure big data business-critical sharepoint accessibility android apple chrome clear people clearpeople debug emulator ios mobile testing opera resize adobe desktop flash ie10 internet explorer 10 metro windows 8 bcsp Advanced System Reporter reporting framework ControlMode form control master page placeholder publishing console SharePoint 2007 SharePoint error search search results search values software testing testing scenario audit content information architecture retention schedules PowerShell QuickLaunch scripts SharePoint server 2010 business solutions metalogix replication replicator storagepoint stena technet UK Technet picture library slideshow web part RTM released to manufacturing caml caml query MOSS 2007 query infopath