PowerShell: Updating an Azure Service Display Name

If you’re like me, you probably like clarity, consistency, and conciseness. Given that, I like to ensure that names of hosted services in Windows Azure are named appropriately. Sometimes developers will give a service a quick name that they understand, but may not relay enough information to other team members, at a glance, as to what that service does.

Thankfully, this is easily rectified using a simple PowerShell command. Assuming that you have already configured your Windows Azure PowerShell cmdlets according to my recent “Introduction to Azure PowerShell Module” article, you can simply run the following command to update the Label (aka. “friendly name”) of a Windows Azure hosted service.

[cc lang=”powershell”]
# Select the Windows Azure subscription that we are working with (must be configured using Set-AzureSubscription)
Select-AzureSubscription -SubscriptionName Development;
# Set the new friendly name (label) for the service
Set-AzureService -ServiceName MyService -Label “This is my new service label”;
[/cc]

If you want to take it one step further, you can build a .NET [cci][HashTable][/cci] of key-value mappings that link service names to their respective labels. Then, once you’ve got the mapping, you can simply iterate over it and call [cci]Set-AzureService[/cci] for each entry. This method is a lot more flexible and efficient with writing code 🙂

[cc lang=”powershell”]
# Select the Windows Azure subscription
Select-AzureSubscription -SubscriptionName development;

# Build a HashTable of service names and labels
$ServiceList = @{
‘Service1’ = ‘My First Service’;
‘Service2’ = ‘My Second Service’;
‘Service3’ = ‘My Third Service’;
};

# For each service entry in the HashTable, update the Label field
foreach ($Service in $ServiceList.Keys) {
Set-AzureService -ServiceName $Service -Label $ServiceList[$Service];
};
[/cc]

Pretty easy, isn’t it?

“Why go through all that effort? I’ll just do it through the UI.”

Did I happen to mention that the Windows Azure Silverlight user interface (UI) doesn’t even allow you to change the label / friendly name of a hosted service once it has been created? Yes, it’s true (as far as I know). The only option to re-label an Azure hosted service through the management UI, once it has already been defined, is to delete the existing service definition, and recreate it. That doesn’t sound like a viable option in a production environment now, does it? 🙂

Until next time … enjoy scripting ALL the things in PowerShell!