When you create an Azure storage account, by default, it can only be accessed via it’s native name that Azure give it, in the format of http://<your storage account name>.blob.core.windows.net. This may suit your requirements, but sometimes you may want to change it so that it looks like the content is hosted at your website. One of the main reasons would be to perhaps give your users a greater sense of security, because as far as they’re concerned they’re downloading content directly from your website and not some unknown 3rd party (as far as they’re concerned). In this article I’ll describe how to change the URL of your storage account to make it appear as though the content is hosted on your website.
Creating Your Storage Account:
- Click on “STORAGE” then new
- Type in the name you would like to give your storage account
- Select a region where you would like the storage account hosted at (pick the same as where your website is located at)
For replication, choose the option which best suits you.
- Locally redundant means that there are backup copies, but only within the same region (So if a meteor hits that part of the earth, your files are gone forever).
- Geo-Redundant means that you’re images are backed up to a secondary region hundreds of miles away, so in the previous example, your files would still survive.
- Your storage account will now appear under the storage tab (That you first clicked on) along with your other storage accounts.
Choosing Your Custom Domain Name
Click on your newly created storage account
- Click on configure, then click on “manage domain” at the bottom of the page
Type in your custom domain name.
It will have to be a subdomain domain name.
You won’t be able to make it point to mysite.com/images unfortunately, it may be possible with 301 redirects but I imagine it will get messy very quickly.
It will instead have to be something content.mysite.com, but you can have a container name (Discussed later) called “images”, so you would end up with content.mysite.com/images
Using a subdomain has the benefit of improving your page speed, which will ultimately have a positive effect on your SEO efforts.
I’ll go into detail later.
At the moment, this won’t work.
As you can see, Azure is asking you to have a CNAME record (canonical name) for your domain with your DNS provider.
This is where it gets a little complicated, it’s a little daunting the first time, bit you’ll see that it’s very easy and not something to be scared of.
- It will have to be a subdomain domain name.
Adding DNS Records For Your Custom Domain
- Go to your domain host (GoDaddy for example) and navigate to your domain management page.
You will see several fields:
- The subdomain that you have chosen to for Azure to use.
The location that Azure instructed you to point your CNAME to.
This will be <Your storage account name>.blob.core.windows.net
In my example, this would be mycustomstorageaccount.blob.core.windows.net
- The location that Azure instructed you to point your CNAME to.
- You’ll want to select CNAME here.
TTL (Time To Live)
This indicates in seconds how frequently the DNS details should be refreshed for this rule.
Setting it low initially is fine, but once you’ll got everything all set up, set this back to a longer value to make the queries required to look up the DNS records for your domain less frequent.
- This indicates in seconds how frequently the DNS details should be refreshed for this rule.
- Host Name
Setting Up Your Container
Go back to Azure and it should now allow you to use the subdomain of your custom domain selection.
- For me it worked right away, but sometimes it can take a little while to get picked up.
Click on your storage account.
- Don’t worry that under endpoints it still says the original Azure path representing your storage account, it’s perfectly normal.
- Click on “Containers” at the top of the page and then click on “Create a container”.
- Type in a name for your container, this will appear as if it were a sub directory under <your subdomain>.<your custom domain>/<container name>
- In the “Access” dropdown, select “Private” if you don’t want anyone else to see it’s contents, or “Public Blob” if you want it to be visible to everyone (Which will probably be the case if you’re trying to use your storage account to host images for your website for example).
You’re now able to access your container and upload your blobs.
You can use visual studio in the server explorer panel to achieve this, or one of the popular Azure Storage explorers (Link http://blogs.msdn.com/b/windowsazurestorage/archive/2014/03/11/windows-azure-storage-explorers-2014.aspx)
By: Stephen Warren