May 072014
 
 May 7, 2014  Posted by at 1:04 pm Azure, PowerShell Tagged with:  Add comments

Creating and uploading to Azure blob storage with Azure PowerShell
I’ve started a new video and audio series (I guess we can them podcasts?) with ‘(not so) Stupid Questions’, and while I’ve chosen to have the videos on YouTube (for now) the question was where to put the audio file? Azure of course! I’ve been wanting to dig deeper and learn more about Azure ever since I moved my site to Azure Websites from a generic host, so this is the perfect opportunity. I’m also setting up an Azure VM for some build work, so expect more on Azure as I learn new things.

The first thing I’d like to share is how to use Azure CDN, and use PowerShell to push content to a blob container. Please keep in mind that I’m learning as I’m going, so this might not be best practices or a fully featured demo.

Simply put, the steps for this is as following:

1. Create storage

Azure CDN With PowerShell

Azure CDN With PowerShell2

2. Add CDN for storage

Azure CDN With PowerShell3

Azure CDN With PowerShell4

3. Create container

Azure CDN With PowerShell5

Select create container

Azure CDN With PowerShell7

3. Download  Azure PowerShell tools

Azure CDN With PowerShell8

4. Add-AzureAccount, Get-AzurePublishSettingsFile, Import-AzurePublishSettingsFile <path to dowloaded file.

Open Azure PowerShell and run the above commands, use Get-Help for help

Azure CDN With PowerShell9

Azure CDN With PowerShell10

Azure CDN With PowerShell11

5. Upload blob

Creating and uploading to Azure blob storage with Azure PowerShell

$myContext = New-AzureStorageContext -StorageAccountName $MyName -StorageAccountKey $MyKey

Set-AzureStorageBlobContent -Blob nameOfBlob -Container MyName -File pathToFile.jpg -Context $myContext

Thank Nik (http://www.nikgupta.net/) you for the above snippet on StackOverflow (http://stackoverflow.com/questions/18795815/get-azurestorageblob-throws-can-not-find-your-azure-storage-credential).

There are other ways to go about this, I’ll try a few more things and update the post and add some more posts as I learn new things. Hope this helps 🙂

 

 Leave a Reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

(required)

(required)

What is 6 + 9 ?
Please leave these two fields as-is:
IMPORTANT! To be able to proceed, you need to solve the following simple math (so we know that you are a human) :-)