I recently setup Active Directory on a VM inside an Azure Virtual Network. Unfortunately, the Virtual Network DNS entry was not put in before creating and working with the Active Directory VM.
Because of Azure's framework, I believe I have to recreate the VM (after making the DNS change). Does anyone know how to take a snapshot of the virtual hard-drive and re-associate that with a newly created VM after the DNS change is made. I have read information about sysprep to capture an image but I'm afraid that will corrupt various AD settings.
Also, does anyone have any other information about this type of DNS change?
Thanks,
akgh
Here are the steps:
First export the VM configuration to an XML file
get-azurevm -servicename [service name] | export-azurevm -path [local path]
This generates a small XML file that contains information about the VM.
Next, remove the VM configuration from Azure.
remove-azurevm [VM name]
This does not actually delete the VHD file, it only removes the configuration about the VHD that you have previously backed-up/exported from step 1. So there is no danger or destruction done here. These are actually the same steps you would do if you wanted to stop paying for the service.
Now, restore the VM configuration with the new DNS settings you want.
$dnslocal=New-AzureDNS -Name "my Azure DNS Server" -IPaddress "192.168.10.4"
$dnsonprem=New-AzureDNS -Name "my OnPrem DNS Server" -IPaddress "172.16.83.21"
Import-AzureVM -Path 'E:\myVM.xml' | New-AzureVM -ServiceName 'myVM' -Location 'West US' -DnsSettings $dnslocal,$dnsonprem -VNetName "MyVNET" –AffinityGroup “CATAFF1”
Note: You may get an error when trying to import the VM configuration. If you get an error that the DNS name already exists, then you may need to remove the cloud service
remove-azureservice –servicename “myVM"
Related
Can't we Move a Microsoft Azure VM to a Different Subnet Within a vNet using the azure new portal or the azure classic portal ? if not possible through portal then how to do so ?then how to edit the properties of a VM after creation, like moving to a different subnet,, etc.,?
It is possible through the new portal. First I want to ask you if you're using a Classic VM or a Resource manager VM. If you're using the last one you can easily switch between subnets by changing the configuration settings.
go to your network interface > Ip configurations and click on the Nic name (see picture below)
A new tab will open and you can change the Subnet of the nic.
If your vm is a classic one, moving it to different vNet is very easy using azure powershell cmdlets. Here is the code-
$vmName = "xxxxx"
$srcServiceName = "xxxxx"
$newVNet = "xxxxx"
# export vm config file
$workingDir = (Get-Location).Path
$sourceVm = Get-AzureVM –ServiceName $srcServiceName –Name $vmName
$global:vmConfigurationPath = $workingDir + "\exportedVM.xml"
$sourceVm | Export-AzureVM -Path $vmConfigurationPath
# remove vm keeping the vhds and spin new vm using old configuration file but in a new vNet
Remove-azurevm –ServiceName $srcServiceName –Name $vmName
$vmConfig = Import-AzureVM -Path $vmConfigurationPath
New-AzureVM -ServiceName $srcServiceName -VMs $vmConfig -VNetName $newVNet -WaitForBoot
if not possible through portal then how to do so ?then how to edit the properties of a VM after creation, like moving to a different subnet,, etc.,?
It could be done with Powershell. In brief, it contains 3 steps:
Get the VM (NIC) configuration
Edit the VM (NIC) configuration
Update the edited configuration
Note: Moving VMs between different VNET is not supported. To move the VM to another VNET, the only solution for now is re-create the VM with the same vhd file.
Here is a good step-by-step guide:
How to change Subnet and Virtual Network for Azure Virtual Machines (ASM & ARM)
I'm currently on an Azure free trial and trying to setup a reverse DNS PTR record.
I've logged in via certificate, downloaded the file using: Get-AzurePublishSettingsFile. I've also imported the file using Import-AzurePublishSettingsFile C:certs<SubscriptionName>-credentials.publishsettings.
However, when I run Get-AzureService | fl ServiceName I don't get any services listed.
When I try and run Set-AzureService –ServiceName "my hostname" –Description "Reverse DNS" –ReverseDnsFqdn "mail.my domain."
I get The hosted Service name does not exist.
Is there a limitation on the free trial that doesn't allow this to be set?
After Import... add
Select-AzureSubscription -SubscriptionName "nameofyoursubscription"
Just importing your subscription publish settings file does not select the subscription you need.
UPD: i was not able to reproduce the issue. Please try to execute:
$subscr = "subscriptionid"
$csname = "mytestcloudservice14"
Select-AzureSubscription -SubscriptionId $subscr –Current
New-AzureService -ServiceName $csname -Location "Central US" -Label "mytestcloudservice"
Set-AzureService –ServiceName $csname –Description "Reverse DNS" –ReverseDnsFqdn "mytestcloudservice14.cloudapp.net."
Get-AzureService -ServiceName $csname
I just created the trial account and tested it.
As the description of Get-AzureService says, it returns an object with information about the cloud services for the current subscription, which means, it's an operation on Azure cloud service only, Set-AzureService as well.
So if you didn't deploy any cloud services, Get-AzureService will definitely list nothing and if your "my hostname" is not cloud service, it's no wonder you get the error message The hosted service does not exist..
In addition, Reverse DNS is not supported for Azure Websites. Reverse DNS is supported for Azure PaaS roles and IaaS virtual machines.
I have created 2 Virtual Machines (VMs) using RM (Resource Manager) deployment method. How can I clone a VM using Azure PowerShell scripts?
You can follow the documentation guide here: https://azure.microsoft.com/en-us/documentation/articles/virtual-machines-windows-capture-image/
After you Open the Azure PowerShell and login to your Azure account.
You can find the subscriptions your Azure account has by using the command Get-AzureRmSubscription.
Next you will need to deallocate the resources used by this virtual machine.
Stop-AzureRmVM -ResourceGroupName YourResourceGroup -Name YourWindowsVM
Next you need to set the status of the virtual machine to Generalized. Note that you will need to do this because the generalization step above (sysprep) does not do it in a way that Azure can understand.
Set-AzureRmVm -ResourceGroupName YourResourceGroup -Name YourWindowsVM -Generalized
Next, Capture the virtual machine image to a destination storage container using this command.
Save-AzureRmVMImage -ResourceGroupName YourResourceGroup -VMName YourWindowsVM -DestinationContainerName YourImagesContainer -VHDNamePrefix YourTemplatePrefix -Path Yourlocalfilepath\Filename.json
The -Path variable is optional and can be used to save the JSON template locally. The -DestinationContainerName variable is the name of the container that you want to hold your images in. The URL of the image stored will be similar to https://YourStorageAccountName.blob.core.windows.net/system/Microsoft.Compute/Images/YourImagesContainer/YourTemplatePrefix-osDisk.xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx.vhd. It will be created in the same storage account as that of the original virtual machine.
The Azure documentation offers a detailed guide to do this, so follow the instructions and in case of trouble, you can ask me!
BEWARE! When you sysprep your machine and make it generalized, you CANNOT UnDO this!!!
This means that you VM will stay stopped (deallocated) and you can create infinite cloned from this, but you cannot start this again, so make sure it is not in production :)
After switching to the new Azure portal, I see all resources of mine are listed as classic resources. I am googling around to see if it's possible to have classic VM and migrate it to ARM and just hadn't seen anything that stated it was possible.
I tried deleting the class VM but keep the VHD to check if I can attach it to the ARM VM. The result said it doesn't work.
Is there any way that can be used to achieve this ?
Unfortunately (and strangely!) there isn't a way to do this via the portal and you have to drop down to Powershell instead (or xplat / Rest)
When I have exported VMs from v1 to v2 I typically make the original vhd file accessible via a blob share (this can be done temporarily for the duration of this command)
You can then deploy a new VM using that vhd as a source image's URI, using
Set-AzureRmVMOSDisk -VM $vm -Name $vmname -VhdUri $uri -CreateOption FromImage -Windows
Alternatively you can copy the vhd to v2 storage and use Attach instead of FromImage
If you wrap that around a standard VM Create script, you should be good to go!
There is a set of powershell scripts to assist in migrating classic vms to the new resource group model - asm-arm
They require the Azure and AzureRM powershell modules - msdn link to installation instructions
I have configured a CMS solution in my Linux Virtual Machine on Azure and want to add this VM with my Virtual Netork. I am unable to add my existing Linux Virual machine to Virtual Network.
Any help is greatly appreciated.
As your Linux VM was created first and Virtual Network (VNet) was created after, your Linux VM may not be able to see the Virtual Network.(This is a known issues with Linux VM)
You can follow given steps to achieve your objective:
Delete the current VM (this will still keep the VHD stored in Azure Storage)
Now go to Virtual Machines > Disks, and find the OS disk you want to use and select Delete Disk. This does not delete the VHD, only unregisters it as a disk
Now create an OS image from your Saved VHD, which was use for previous VM
Now create a VM from OS image (#3)
This way you will have your VM ready and now to add it to VNet.
Now because you are using Linux VM to connect with VNet, there is one problem. You can not do it with your Linux VM as Windows Azure Manager Portal does not support this feature so you would need to use PowerShell command (on Windows) or Cross-Platform tools (on Mac and Linux) to achieve your objective.
Following are the command you will use to create a new VM using an OS Image and Virtual Network:
$vm = New-AzureVMConfig -Name $vmname -InstanceSize ExtraSmall -ImageName $image | Add-AzureProvisioningConfig -Linux –LinuxUser $linuxUser -Password $adminPassword | Set-AzureSubnet -SubnetNames $subnet
New-AzureVM -ServiceName $cloudSvcName -AffinityGroup $affinitygroup -VNetName $vnetname -VMs $vm
http://www.zdnet.com/blog/microsoft/microsoft-to-enable-linux-on-its-windows-azure-cloud-in-2012/11508
To date, Microsoft has been balking at customer requests to add
persistent VMs to Azure, hoping to get customers to develop Azure apps
from scratch instead
...
Running Linux on Azure has been a
surprisingly big business-customer request, as well, my contacts
said
...
The Register reported earlier this year that Microsoft was
testing the ability to run Linux on Azure in its own labs, and that
the launch of such a capability was still months away.
There are tons of VPS services out there where you can run any OS you want, quite reliably and quite inexpensively. Apparently, Azure isn't one of them :)