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
After that you login into your Azure RM Account using the cmdlet
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.
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
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.
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,