Azure-cli: az vm create should have a parameter to set osprofile.computerName (hostname)

Created on 31 Jan 2019  路  10Comments  路  Source: Azure/azure-cli

Is your feature request related to a problem? Please describe.
Yes. I can create a VM from one of my images easily for everything including networking but for some reason there isn't a parameter to set osprofile.computerName (ie the hostname) of the new VM.
I need this almost everyday and I have to resort to a group deployment with templates and many files just to set up a simple VM

Describe the solution you'd like
there should be a --computer-name switch to specify the hostname of each created VM.

Describe alternatives you've considered
I have to go through the hassle of a az group deployment with JSON files for this simple thing.

Additional context
Add any other context or screenshots about the feature request here.

Compute-cli question

Most helpful comment

For this case, where there is a parameter that can only be set on creation and can't be updated, I would advocate for exposing the strongly-typed argument.

All 10 comments

@carlosvsilva, the host/computer name of the VM is set to the name of the VM. To better help me understand your issue, is there a reason why you would want the name of the VM resource to be different from the computer/host name?

@adewaleo Hi thanks for your interest in this issue. I would like total freedom to name my VM in Azure Portal listings instead of being restricted to 15 alphanumeric characters per Windows hostname limitations.
So if I can set the Windows/Linux hostname in the command line with --computer-name switch , the name of the VM in Azure is freed to use more characters (15 is too short) and I can have finally my VM named "MasterVM-201902131034".

Right now to achieve this result I have to go through a az group deployment templates which has the unfortunate side effect of ruining images to scalesets, since the hostname defined in the template always stays the same and doesn't change automatically according to computerNamePrefix of the VMScaleSet :(

Okay @carlosvsilva, thanks for explaining. I will work on adding the option. I should be able to add it by two releases time (maybe even the next release).

Perfect! Thank you very much.

Will work on generic set for vm, post build(eventually vmss and avail set).

For this case, where there is a parameter that can only be set on creation and can't be updated, I would advocate for exposing the strongly-typed argument.

For this case, where there is a parameter that can _only_ be set on creation and can't be updated, I would advocate for exposing the strongly-typed argument.

@tjprescott, I was for the idea, but @yugangw-msft had some reservations against it. See #8538

I am still open to it though, @tjprescott

@carlosvsilva. fyi, --computer-name has been added to vm create.

Thank you very much :) I will be sure to use it.

Best regards,
Carlos

Was this page helpful?
0 / 5 - 0 ratings