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 designdevelopment 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.

123## Sign in with Azure CLI az login

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

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

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.

123## Get a list of subscriptions for the logged in account with their subscription ID, subscription name, tenant ID and their current state Get-AzSubscription
Azure Governance: Rename an Azure Subscription with Azure CLI and PowerShell

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.

123## 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.

123## 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.

This blog is part of Azure Week. Check it out for more great content!

About the Author:

Wim is an Azure Technical Advisor, who has more than fifteen years of experience with Microsoft Technologies. As a Microsoft Certified Trainer (MCT), his strength is to assist companies in the transformation of their business to the Cloud by implementing the latest features, services and solutions. Currently his main focus is on the Microsoft Hybrid Cloud Platform and especially on Microsoft Azure and the Azure hybrid services.

Wim is also a Microsoft MVP in the Azure category and a founding board member of the MC2MC user group.

As a passionate community member he regularly writes blogs and speaks about his daily experiences with Azure.

Reference:

Matthyssen, W. (2021). Azure Governance: Rename an Azure Subscription with Azure CLI and PowerShell. Available at: https://wmatthyssen.com/2021/04/21/azure-governance-rename-an-azure-subscription-with-azure-cli-and-powershell/ [Accessed: 8th July 2021].

Share this on...

Rate this Post:

Share: