Permalink
Fetching contributors…
Cannot retrieve contributors at this time
58 lines (41 sloc) 2.39 KB
title description services documentationcenter author manager editor ms.assetid ms.custom ms.service ms.workload ms.tgt_pltfrm ms.devlang ms.topic ms.date ms.author
Azure PowerShell Script Sample - Rotate storage account access key | Microsoft Docs
Create an Azure Storage account, then retrieve and rotate one of its account access keys.
storage
na
tamram
timlt
tysonn
mvc
storage
storage
na
azurecli
sample
06/13/2017
tamram

Create a storage account and rotate its account access keys

This script creates an Azure Storage account, displays the new storage account's primary access key, then renews (rotates) the key.

[!INCLUDE sample-powershell-install]

[!INCLUDE quickstarts-free-trial-note]

Sample script

[!code-powershellmain]

Clean up deployment

Run the following command to remove the resource group, storage account, and all related resources.

Remove-AzureRmResourceGroup -Name rotatekeystestrg

Script explanation

This script uses the following commands to create the storage account and retrieve and rotate one of its access keys. Each item in the table links to command-specific documentation.

Command Notes
Get-AzureRmLocation Gets all locations and the supported resource providers for each location.
New-AzureRmResourceGroup Creates an Azure resource group.
New-AzureRmStorageAccount Creates a Storage account.
Get-AzureRmStorageAccountKey Gets the access keys for an Azure Storage account.
New-AzureRmStorageAccountKey Regenerates an access key for an Azure Storage account.

Next steps

For more information on the Azure PowerShell module, see Azure PowerShell documentation.

Additional storage PowerShell script samples can be found in PowerShell samples for Azure Blob storage.