Azure Azure CLI Azure Governance Azure PowerShell

Azure Governance: Rename an Azure Subscription with Azure CLI and PowerShell


This blog post will show you how you can change the name of an Azure Subscription with the use of Azure CLI and Azure PowerShell.

When a proper Azure governance model is followed, you can ensure that your teams are operating in a secure and compliant Azure environment during design, development and operations. In this way you can not only minimize operational and reputational risks, but it will also help you to secure and to remain in control of your Azure environment.

As part of your Azure governance strategy, and also as a good starting point when setting up any new Azure environment, you should use a consistent well-defined naming convention for all your Azure resources. And off course this also applies for the naming of your Azure subscriptions.

If you want to read some more about applying a good and useful Azure naming convention, then you can always check out the following Microsoft Docs links. Develop your naming and tagging strategy for Azure resources and Recommended abbreviations for Azure resource types, which are both part of Microsoft’s Cloud Adoption Framework (CAF).


Rename an Azure Subscription


Open Windows Terminal (Run as administrator) and run following Azure CLI login command.

## Sign in with Azure CLI

az login

When a browser opens, sign in with your account credentials.


Before you can rename any Azure subscription your first need to know it’s subscription Id. In order to get a list of all subscriptions in the tenant with their Subscription Id from the account who is currently logged in, you need to run the following Azure PowerShell cmdlet.

## Get a list of subscriptions for the logged in account with their subscription ID, subscription name, tenant ID and their current state

Get-AzSubscription


When you found the subscription Id for the subscription you want to rename in the list, copy it and run the below CLI command to rename the subscription.

In the CLI command you just need change “xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx” with the copied subscription Id and “new subscription name” with your preferred new subscription name.

## Rename subscription

az account subscription rename --subscription-id "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" --name "new subscription name"


After running the above CLI command, you can check if the rename was successful by running the following Azure PowerShell cmdlet.

## Get a list of subscriptions for the logged in account with their subscription ID, subscription name, tenant ID and their current state

Get-AzSubscription


Off course, you can also use the Azure Portal to see if the renaming was successful. Just be aware that it can take up to 10 minutes before the naming is applied and visible.

When logged into the Azure Portal with your account, type sub into the global search box. Then select Subscriptions.


On the Subscriptions window you can then see if the renaming of the subscription was successful.



Conclusion

As part of your Azure Governance strategy, you should use a good and well-defined naming convention for your Azure Subscriptions, just like for any other Azure resource.

To apply your naming convention to your Azure Subscriptions you can use the Azure Portal, but as shown in this blog post you can also use Azure CLI and Azure PowerShell to rename them.


%d bloggers like this: