Setting a Web/Worker Role Name
I was recently reminded by my friend Nuno that you can actually set the name of the machine used in a Windows Azure Cloud Service (Web or Worker Role). Normally I really don’t care about the name of the machine. I’m fine with RD-whatever.
If I did care, there is a way to set that machine name. There is a “vmName” attribute in the Role element of the role’s .cscfg file.
<?xml version="1.0" encoding="utf-8"?> <ServiceConfiguration serviceName="CloudServiceName" xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceConfiguration" osFamily="3" osVersion="*" schemaVersion="2013-10.2.2"> <Role name="WebRole1" vmName="CollierWeb"> <Instances count="1" /> <ConfigurationSettings/> </Role> </ServiceConfiguration>
Doing so will result in the machine name being set to whatever is in the “vmName” attribute, appended with the instance number (0, 1, 2, etc.)
Note that the role name will still be whatever is set in the .cscfg, appended with the instance number.
For more on the schema of the .cscfg file, please see MSDN.
(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)