Using Azure Storage with Powershell – Getting started
- You’ll need an Azure subscription. You can get a free trial here.
- I’m using a Server 2012 R2 machine. First, download and install Microsoft Web Platform Installer
- After installation, type in Azure in the search field, click the search icon, then click Install to see installed modules on top:
- Close the Microsoft Web Platform Installer. To get back to it to add/remove modules you can use the icon:
- Notice the new Azure set of icons added:
- I’ve pinned the Azure Powershell icon to the task bar. Open it by right clicking on it, then right click on Windows Azure Powershell and click Run as administrator
- To connect to your Azure account, type in Add-AzureAccount
- Azure Powershell displays a message similar to:
- Check your subscription(s) using the command: Get-AzureSubscription
- If you have more than one subscription under your Azure account, you may want to switch to a specific subscription. Use this command to switch a given subscription and make it the default subscription: Select-AzureSubscription -SubscriptionName “Visual Studio Premium with MSDN” -Default
Substitute “Visual Studio Premium with MSDN” with SubscriptionName as shown from the Get-AzureSubscription command
If you don’t have a storage account setup under your Azure subscription, you can create one from your Azure portal. Click Storage on the left, then click New at the bottom:
Type in a name for the new account you wish to create – must be lower case letter only. Pick an Azure data center – typically one that’s physically close to your location to get better latency. Pick a subscription. Pick a replication setting. Locally-redundant give you 3 copies of your data in the data center you selected. Geo-redundant gives you 3 additional copies in another Azure data center. Geo-redundant is typically twice the cost of locally-redundant storage account, and is the default option.
In a minute or 2 Azure will finish creating the storage account. click on the account name:
Next click Dashboard, and click Manage Access Keys at the bottom:
Copy the account name and the primary access key. You will need them to use your storage account via Powershell later.
Secure this information because it provides access to your Azure data. Data can be accessed by using either the primary or secondary keys. Each key is 88 characters long and is made up of alphanumeric upper and lower case letters and special characters. The availability of 2 keys allows us to change keys without losing access by applications or machines that use the account. For example in case of key compromise, and you’re using the primary key in an application or machine, you can:
- Regenerate the secondary key
- Replace the key in the script/application/machine using the storage account (no access interruption)
- Regenerate the primary key
Now you have changed your account keys without any service interruption