How to use Azure storage for sharing files

Some blog posts ago I’ve promised to explain the easiness of sharing files using Azure storage. Today’s the day!

First of all make sure that you have Azure PowerShell module 1.4.0 or newer installed. I’ve used module 1.5.0 from June, 1st 2016. You can test your PowerShell module’s version with the following command:

$(get-module -name azure).version

002_PowerShellModuleVersion

After that you login into your Azure RM Account using the cmdlet

Login-AzureRmAccount

If you have not done so yet, now is the time to create a new Azure Resource Manager Storage Account using the PowerShell command

New-AzureRmStorageAccount -ResourceGroupName 'YourRGName' `
-AccountName rmcoolblob2 `
-Location NorthEurope `
-SkuName Standard_LRS `
-Kind BlobStorage `
-AccessTier cool

With that command I have created a new blob Storage Account with cool access tier and no replication between Azure datacenters.

003_RG_1

Now you need a storage container you can place your files into. So set your PowerShell session to default to your Storage Account and create the container:

Set-AzureRmCurrentStorageAccount -StorageAccountName rmcoolblob2 -ResourceGroupName 'YourRGName'
### Notice that the following cmdlet does not have a 'Rm' for Resource Manager in its name...
New-AzureStorageContainer -Name blobcontainer

004_1

With the command

set-AzureStorageContainerAcl -Name blobcontainer -Permission blob

you can grant read access to the files you want to upload to your account. Now what’s left to do is upload your file(s):

Set-AzureStorageBlobContent -Container blobcontainer -File .\test.txt

Now you can access that file via browser. Whether it’s displayed or downloaded depends on the file format. .txt-files for example are displayed, .zip-files are downloaded.

With the URL https://rmcoolblob2.blob.core.windows.net/blobcontainer/test.txt you can access my test file.

005_Testfile

Under https://rmcoolblob2.blob.core.windows.net/blobcontainer/test.zip you can access the same file packed in a zip-package that can be downloaded.

I hope I could make clear how easy it is to share files with the world using Azure Storage Accounts.

Have fun sharing your own files and stay tuned,

Kind regards,
Tom

Author: Thomas Janetscheck

Microsoft MVP - Azure | Cloud Solutions Architect | Community Leader | Speaker

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s