chef/knife-azure

unable to use existing storage account / Vnet while creating new VM

Closed this issue · 3 comments

Hi,

Is it possible to make use of existing storage account / virtual account (belonging to a different resource group, say 'abc') while creating a new VM (belongs to xyz resource group) on azure using "knife azurerm server create" command?

the below command has a storage account that is already existing, but the command adds a prefix to the storage account name.

knife azurerm server create --azure-resource-group-name 'lab-chefserverautomate-rg' --azure-vm-name 'testsrv01' --azure-service-location 'eastus2' --azure-image-reference-publisher 'MicrosoftWindowsServer' --azure-image-reference-offer 'WindowsServer' --azure-image-reference-sku '2012-R2-Datacenter' --azure-storage-account 'labchefserverrgdiag243' --winrm-user 'azureuser' --winrm-password 'myPassword123' --node-ssl-verify-mode none --azure-vm-size Small --no-node-verify-api-cert -N 'testsrv01'-VV

ERROR: hbilugacvjebilabchefserverrgdiag243 is not a valid storage account name. Storage account name must be between 3 and 24 characters in length and use numbers and lower-case letters only.

when similar command is run with --azure-vnet-name and --azure-vnet-subnet-name it creates the vnet / subnet in xyz resource group. I tried giving the full resource id of the vnet / subnet from 'abc' resource group. but it doesn't work.

Also, is there an option to disable the "public ip" while creating the VM?

Thanks!

@chefuser13, Under any subscription we can't use existing storage account from a resource group because that is unique for the subscription. So we prefix random string with storage account name while creating Azure ARM VM. This is the reason you get invalid storage account name ERROR.

Also there is no such option available to disable/disassociate public IP while creating Azure ARM VM. You can achieve that after creation of your VM.

reference to https://stackoverflow.com/questions/46398694/how-to-detach-dissociate-public-ip-of-arm-vm

PS Command to disable public IP:

You need to get the Network Interface object and remove the Ip Address Id from it and push changes back to Azure.

$nic = Get-AzureRmNetworkInterface -Name bla -ResourceGroup blabla
$nic.IpConfigurations.publicipaddress.id = $null
Set-AzureRmNetworkInterface -NetworkInterface $nic

Hope it helps. Thanks

@chefuser13, Got a chance to look at it?

Closing this based on above comments.

Thanks