Is it possible to Rotate Azure classic storage account keys using az commands ?


Hi need support to find a way to rotate azure classic storage account keys ( don't have azure portal UI access trying to connect via 1ES secure pool agent pipeline ), at the moment I am using following document to do so:

az storage account keys renew --account-name
--key {primary, secondary}
[--key-type {kerb}]

I do have storage account (classic storage account) name and resource group name with me but not able find any attribute to instruct above command to run for classic storage account type while renewing the keys however its picking up normal storage account by default and key renewal failing by stating following error message ' storage account not found in the resource group '.

Message: The Resource 'Microsoft.Storage/storageAccounts/<storage-account>' under resource group '<rg>' was not found, where as

az resource list --query "[?name=='<storage-account>']" command returning <rg> correct name along side type which is:

"type": "Microsoft.ClassicStorage/storageAccounts"


Azure Storage Accounts
Azure Storage Accounts
Globally unique resources that provide access to data management services and serve as the parent namespace for the services.
2,747 questions
0 comments No comments
{count} votes

Accepted answer
  1. deherman-MSFT 34,021 Reputation points Microsoft Employee


    I understand you are trying to rotate the key for your classic storage account using the CLI. Please correct me if I am misunderstanding.

    Classic storage account is not supported in the latest CLI as it does not use the ARM deployment model. More information about this can be found here. Migration from classic to ARM is possible and I would recommend looking into performing this in the future.

    In order to manage classic resources via CLI you must install the classic CLI. Once the classic CLI is installed you can run the following to login, set subscription, change config mode, then rotate the key.

    azure login  
    azure account set "subscriptionname"  
    azure config mode asm  
    azure storage account keys renew storageaccountname --primary or --secondary  

    Hope this helps you. Let me know if you run into any problems or have further questions.


    Please don’t forget to "Accept the answer" and “up-vote” wherever the information provided helps you, this can be beneficial to other community members.

    1 person found this answer helpful.
    0 comments No comments

0 additional answers

Sort by: Most helpful