Arm Template -VM from existing vnet and all dependent resources - azure

I want to create ARM template to deploy Azure VM on its already created dependent resources. Want to deploy a vm on these existing dependent resources : Storage Account, Diagnostic Storage Account, Virtual Network, Network Interface, Public IP Address, Network Security Group.

You can use those dependent resources as parameter and use it in your arm file.

You can take help of this example:
https://github.com/Azure/azure-quickstart-templates/tree/master/201-vm-different-rg-vnet
And update the ARM template according to your requirements.

Related

Azure Backup Policy only work with two VMs

I use Azure Backup Policy to Configure the Azure VMs with Azure Backup.
I use the Tag "backup" with the Value for the Azure Backup Policy. For Example, "default/longtimearchive/ etc."...
Now when I deploy this Policy on the Subscription, I only found 2 VMs.
But I have more than 6 VMs with this Tag.
I have checked the Follow:
Subscription = Correct
The location from The Vault and the VM is the same.
The Tag is set. I have checked it with Powershell.
I have tried to use an other Tag+Value, but it doesn't work.
Why found I only 2 of these 6 VMs?
When I used the Policy "Azure Backup should be enabled for Virtual Machines," I found all of the VMs.
Thanks a lot.
Best Regards,
Phil
Few things to check:
Make sure that the VMs are within the scope of the policy. The scope of the policy can be defined by resource group, subscription, or individual VMs. If the VMs are not within the scope of the policy, they will not be included in the policy.
For VM's with unmanaged disks; If the VMs are in a "stopped" or "deallocated" state, they will not be included in the policy. Check if the ones not being backed up are unmanaged?
Check the tags on the VMs. Make sure that the tags on the VMs match the tags defined in the policy. If the tags do not match, the VMs will not be included in the policy.

How to get the azure VMUUID of azure VM?

I am creating an ARM template for the Azure Log Analytics workspace.it has some queries which use azure VM's VMUUID. Is there is any way to fetch the azure VM's VMUUID inside the ARM template or any other way to fetch azure VMUUID?
ARM Template I just need to get the values of VMUUID of all VM's in that subscription.
You can also get this information programmatically from the Azure Instance Metadata Service (IMDS). It provides information about currently running virtual machine instances. You can use IMDS to manage and configure your virtual machines. This information includes the SKU, storage, network configurations, and upcoming maintenance events. For a complete list of the data available, see the Endpoint Categories Summary.
IMDS is a REST API that's available at a well-known, non-routable IP address 169.254.169.254. You can only access it from within the VM. Communication between the VM and IMDS never leaves the host.
https://learn.microsoft.com/en-us/azure/virtual-machines/windows/instance-metadata-service
Try Azure Resource Explorer
You could easily find it in the Azure Resource Explorer.
//One more extra reference: What is Azure Resource Explorer?
Just navigate to the Microsoft.Compute => virtualMachines view:
There is one more way to find it, but for me seems more complicated as you need to connect to the VM:
https://azure.microsoft.com/en-us/blog/accessing-and-using-azure-vm-unique-id/
Update: Try PowerShell
The simple PowerShell script below returns a list of all VMUUIDs in the specified subscription:
Get-AzSubscription
Select-AzSubscription -SubscriptionId "Olga's Subscription"
$GetVM = Get-AzVM
Foreach ($vm in $GetVM)
{
$vmId =""
$vmId = $vm.vmid
$vmIdList +=$vmId + "`r`n"
}
Write-Output $vmIdList
Please let me know if above answers your question.

Can we recover the azure resource group in azure cloud?

Some times we had deleted the 'resource group' accidentally on azure cloud, its fine that if our/your resource group does not have any deployments on it and we can create immediately newer one and will proceed our stuff, but if we had deployments on it, then its becomes major problem/task.
So can we recover Resource Group? like a recovery of Virtual machine in Azure.
You can export service configurations that belong to a resource group as JSON. Within the portal, there is an option "Export Template" under the Resource Management Navigation Group.
So can we recover Resource Group? like a recovery of Virtual machine in Azure.
Unfortunately, we have no way to recovery it, if the resource group is deleted . We could get the warning if we try to delete resource group from the azure portal. Connect to Azure support team for help maybe a way, but I don't think it could be easy for restoring.
Note : based on my understanding even if we could re-create the resource with ARM template(If we have exported the ARM template before delete), it seems that just with the same resource names with deleted resource that is not equal recovery action.

How can I add Azure VM to existing Vnet or new Vnet using ARM template

I am creating JSON file for ARM template to deploy Azure VM and its dependent resources.
I have created RHEL VM with following resources(all are newly created):-
Storage Account
Diagnostic Storage Account
Virtual Network
Network Interface
Public IP Address
Network Security Group
Now I want to create Azure VM with existing Vnet, Subnet or new Vnet, subnet. Is there any example I can follow up. How can I do so?
Now I want to create Azure VM with existing Vnet
You could refer to this example.
If you want to more templates, you could search the templates gallery to discover what you need.
or new Vnet, subnet.
You could refer to this example, just use an existing resource group.
This is pretty straightforward with Microsoft's documentation.
The challenge here usually lies with understanding the dependencies. In that example, you aren't saying I want this VM to launch in this Vnet, you are saying, "I want this VM to use this NIC which is associated with this Subnet of this Vnet"
It is easiest to just use the example provided at the bottom of that link and work your way forward. With your case, you will end up being able to simply remove the Vnet resource block and add your own Vnet's properties in.
This is an extra tool for working with ARM templates.

Is it possible to choose in which container does an Azure classic Virtual Image is stored?

In Azure Resource Manager (ARM) you can create a Virtual Image from a given VM with command Save-AzureRmVMImage. That command has this parameter:
-DestinationContainerName < String >
Specifies the name of a container. The virtual hard disks (VHDs) that
constitute the VMImage reside in the container that this parameter
specifies. If the VHDs are spread across multiple storage accounts,
this cmdlet creates one container that has this name in each storage
account.
But I am using Classic Service Mode (ASM) and the command Save-AzureVMImage doesn't have that parameter.
So my questions are:
Is it possible to indicate Azure where to store that VM Virtual Image? Any workaround?
Bonus question: Where is that ASM VM Virtual Image stored?
Answer to your 1st question - It is not possible to specify where in classic VM Virtual Images.
Answer to your 2nd question - When you create a classic VM you select a storage account. The images are stored in the same storage account as VM. If you go to that Storage account -> containers-> vhds. you can see them.
If you have not specified any storage account while creating a VM, it will use an auto generated account.
If you want your image to go a specific storage account, you have to first create it and specify it while creating your VM.

Resources