I am trying to develop a clone workflow for my properly working ARM VM running Ubuntu. This VM was created from Bitnami LAMP image in Marketplace.
I am trying to use the -CreateOption attach option instead of fromImage, according my knowledge it should work... I am aware that there is an other option: deprovision->capture->-CreateOption fromImage, but that also have problems see Creating new ARM VM from captured image: Blob name in URL must end with '.vhd' extension error The workflow I followed is according to many description and I do not understand this login issue, hopefully I miss a simple step...
I've tried this workflow twice with different source ARM VMs and got the very same results: The new machine seems fully operational, but I can not log in with the known username password to the new machine (via SSH).
Diagnostics:
- Even the web server and mysql works in the new machine properly, because after the new machine is started I can view the web sites served by it.
- From the script below I've omitted the configuration of inbound rules, but I successfully allowed HTTP (see above) and SSH. The SSH connects asking the password and evaluates it as wrong.
Here is what I've done:
- Stopped the fully functional ARM VM (No waagent -deprovision was ran)
- Copied the OS vhd to a new .vhd blob (Success, the copy script is out of topic)
- Then ran the following script with full success:
.
Login-AzureRmAccount
Select-AzureRmSubscription -SubscriptionName "Visual Studio Premium with MSDN"
# Create VM from an existing image
$location = "westeurope"
$vmSize = "Standard_DS2"
#Existing resource name parameters:
$rgName = "rg-wp"
$vnetName= "vn-wp"
$stName = "mystorage"
#This vhd is a copy of a completely working ARM OS vhd:
$vhdUri = "https://mystorage.blob.core.windows.net/vhds/disk-wp-01.vhd"
#Newly creatable resource names and other parameters
$vmName = "vm-wp-02"
$nicName="ni-wp-02"
$pipName="pip-wp-02"
$nsgName="nsg-wp-02"
$vhdName = "disk-wp-02"
$vnet = Get-AzureRmVirtualNetwork -Name $vnetName -ResourceGroupName $rgName
$storageAccount = Get-AzureRmStorageAccount -AccountName $stName -ResourceGroupName $rgName
$pip = New-AzureRmPublicIpAddress -Name $pipName -ResourceGroupName $rgName -Location $location -AllocationMethod Static -DomainNameLabel $pipName
$nsg = New-AzureRmNetworkSecurityGroup -Name $nsgName -ResourceGroupName $rgName -Location $location
$nic = New-AzureRmNetworkInterface -Name $nicName -ResourceGroupName $rgName -Location $location -SubnetId $vnet.Subnets[0].Id -PublicIpAddressId $pip.Id -NetworkSecurityGroupId $nsg.Id
# Configure VM:
$vm = New-AzureRmVMConfig -vmName $vmName -vmSize $vmSize
$vm = Add-AzureRmVMNetworkInterface -VM $vm -Id $nic.Id
$vm = Set-AzureRmVMOSDisk -VM $vm -Name $vhdName -VhdUri $vhdUri -Linux -CreateOption attach
New-AzureRmVM -ResourceGroupName $rgName -Location $location -VM $vm