This paper introduces the use of Azure Resource Manager The difference between managed and unmanaged disks when the template is pre configured with a virtual machine . This helps to update existing templates from using unmanaged disks to using managed disks . We will use  101-vm-simple-windows  Templates as reference guides . If you want to compare them directly , You can also see the use of Managed disk The template and previously used Unmanaged disk Version of .

Formatting of unmanaged disk templates

First , Learn how to deploy unmanaged disks . When creating an unmanaged disk , Need a storage account to keep VHD file . You can create a new storage account or use an existing account . This article will show you how to create a new storage account . For this purpose , A storage account resource as shown below is required in the resource block .

Copy
{
"type": "Microsoft.Storage/storageAccounts",
"name": "[variables('storageAccountName')]",
"apiVersion": "2016-01-01",
"location": "[resourceGroup().location]",
"sku": {
"name": "Standard_LRS"
},
"kind": "Storage",
"properties": {}
}

Within the virtual machine object , There needs to be a dependency on the storage account , Make sure it's created before the virtual machine . Later on  storageProfile  In the part , Appoint VHD The integrity of the position URI, Used to reference storage accounts and OS Disk and any data disk need it .

Copy
{
"apiVersion": "2015-06-15",
"type": "Microsoft.Compute/virtualMachines",
"name": "[variables('vmName')]",
"location": "[resourceGroup().location]",
"dependsOn": [
"[resourceId('Microsoft.Storage/storageAccounts/', variables('storageAccountName'))]",
"[resourceId('Microsoft.Network/networkInterfaces/', variables('nicName'))]"
],
"properties": {
"hardwareProfile": {...},
"osProfile": {...},
"storageProfile": {
"imageReference": {
"publisher": "MicrosoftWindowsServer",
"offer": "WindowsServer",
"sku": "[parameters('windowsOSVersion')]",
"version": "latest"
},
"osDisk": {
"name": "osdisk",
"vhd": {
"uri": "[concat(reference(resourceId('Microsoft.Storage/storageAccounts/', variables('storageAccountName'))).primaryEndpoints.blob, 'vhds/osdisk.vhd')]"
},
"caching": "ReadWrite",
"createOption": "FromImage"
},
"dataDisks": [
{
"name": "datadisk1",
"diskSizeGB": 1023,
"lun": 0,
"vhd": {
"uri": "[concat(reference(resourceId('Microsoft.Storage/storageAccounts/', variables('storageAccountName'))).primaryEndpoints.blob, 'vhds/datadisk1.vhd')]"
},
"createOption": "Empty"
}
]
},
"networkProfile": {...},
"diagnosticsProfile": {...}
}
}

Formatting of managed disk templates

If you use Azure Managed disk , Disk will be the top resource , No longer requires users to create storage accounts . The managed disk is in  2016-04-30-preview API For the first time in this edition , And in all subsequent API Available in version , Now it's the default disk type . The following sections explain the default settings , How to further customize the disk .

Note

It is recommended to use  2016-04-30-preview  After the API edition , Because in  2016-04-30-preview  and  2017-03-30  There are significant changes between .

Default managed disk settings

To create a VM, No need to create storage account resources , The virtual machine resources can be updated as follows . Special attention ,apiVersion  reflect  2017-03-30, also  osDisk  and  dataDisks  No more for VHD Reference specific URI. If no other properties are specified at deployment time , The disk will use standard LRS Storage . If no name is specified , be OS Disk format  <VMName>_OsDisk_1_<randomstring>, Each data disk is formatted  <VMName>_disk<#>_<randomstring>. By default ,Azure Disk encryption is disabled ; Cache for OS Disk for “ read / Write ”, For data disks, it is “ nothing ”. You may notice that there is still a storage account dependency in the following example , But this is only for diagnostic storage , Disk storage doesn't need .

Copy
{
"apiVersion": "2017-03-30",
"type": "Microsoft.Compute/virtualMachines",
"name": "[variables('vmName')]",
"location": "[resourceGroup().location]",
"dependsOn": [
"[resourceId('Microsoft.Storage/storageAccounts/', variables('storageAccountName'))]",
"[resourceId('Microsoft.Network/networkInterfaces/', variables('nicName'))]"
],
"properties": {
"hardwareProfile": {...},
"osProfile": {...},
"storageProfile": {
"imageReference": {
"publisher": "MicrosoftWindowsServer",
"offer": "WindowsServer",
"sku": "[parameters('windowsOSVersion')]",
"version": "latest"
},
"osDisk": {
"createOption": "FromImage"
},
"dataDisks": [
{
"diskSizeGB": 1023,
"lun": 0,
"createOption": "Empty"
}
]
},
"networkProfile": {...},
"diagnosticsProfile": {...}
}
}

Use top-level managed disk resources

Another option to specify the disk configuration in the virtual machine object is , Create a top-level disk resource , And add in the process of virtual machine creation . for example , You can create a disk resource to use as a data disk as follows .

Copy
{
"type": "Microsoft.Compute/disks",
"name": "[concat(variables('vmName'),'-datadisk1')]",
"apiVersion": "2017-03-30",
"location": "[resourceGroup().location]",
"sku": {
"name": "Standard_LRS"
},
"properties": {
"creationData": {
"createOption": "Empty"
},
"diskSizeGB": 1023
}
}

Later, you can VM Object refers to the disk object to be attached . establish VM when , By specifying in  managedDisk  The resource of the managed disk created in the ID, Allow additional disks . Please note that ,VM Resources  apiVersion  Set to  2017-03-30. Attention, please. , We have created a dependency on the disk resource , Make sure it's creating VM Previously created successfully .

Copy
{
"apiVersion": "2017-03-30",
"type": "Microsoft.Compute/virtualMachines",
"name": "[variables('vmName')]",
"location": "[resourceGroup().location]",
"dependsOn": [
"[resourceId('Microsoft.Storage/storageAccounts/', variables('storageAccountName'))]",
"[resourceId('Microsoft.Network/networkInterfaces/', variables('nicName'))]",
"[resourceId('Microsoft.Compute/disks/', concat(variables('vmName'),'-datadisk1'))]"
],
"properties": {
"hardwareProfile": {...},
"osProfile": {...},
"storageProfile": {
"imageReference": {
"publisher": "MicrosoftWindowsServer",
"offer": "WindowsServer",
"sku": "[parameters('windowsOSVersion')]",
"version": "latest"
},
"osDisk": {
"createOption": "FromImage"
},
"dataDisks": [
{
"lun": 0,
"name": "[concat(variables('vmName'),'-datadisk1')]",
"createOption": "attach",
"managedDisk": {
"id": "[resourceId('Microsoft.Compute/disks/', concat(variables('vmName'),'-datadisk1'))]"
}
}
]
},
"networkProfile": {...},
"diagnosticsProfile": {...}
}
}

By using the VM Create managed availability sets

To use the VM Create managed availability sets , Please put  sku  Object to the availability set resource , And will  name  Property is set to  Aligned. This ensures that each VM Your disks are fully isolated from each other , Avoid single points of failure . Attention, please. , Availability set resource  apiVersion  Set to  2017-03-30.

Copy
{
"apiVersion": "2017-03-30",
"type": "Microsoft.Compute/availabilitySets",
"location": "[resourceGroup().location]",
"name": "[variables('avSetName')]",
"properties": {
"PlatformUpdateDomainCount": 3,
"PlatformFaultDomainCount": 2
},
"sku": {
"name": "Aligned"
}
}

Other scenarios and customizations

To find out about REST API Complete information about the specification , Please check out Create a managed disk REST API file . This document describes other solutions and can be submitted to through template deployment API The default and acceptable values of .

Next steps

stay Azure Resource Manager More about using managed disks in templates

  1. Azure Resource Manager summary

    The infrastructure of an application is usually made up of many components : There could be virtual machines . Storage accounts and virtual networks , or Web application . database . Database servers and third party services . These components don't appear as separate entities , Instead, it appears as related and dependent components of a single entity . Such as ...

  2. stay Azure Resource Manager Set the key vault for the virtual machine in

    Note Azure There are two different deployment models , Used to create and process resources :Resource Manager Models and classic models . This paper introduces the use of Resource Manager Deployment model .Azure Suggestions for most new ...

  3. by Azure Resource Manager Virtual machine settings in WinRM Access right

    Azure Management of service WinRM And Azure Resource Manager Note Azure There are two different deployment models for creating and processing resources :Resource Manager And classic . Ben ...

  4. The plan will IaaS Resource migration from classic deployment model to Azure Resource Manager

    Even though Azure Resource manager provides many wonderful functions , But be sure to plan the migration , To ensure that everything goes smoothly . Taking the time to plan ensures that you don't have problems with migration activities . Note The main participants in the following guidance are Azure Customer consultant team , With ...

  5. Use Azure PowerShell take IaaS Resource migration from classic deployment model to Azure Resource Manager

    The following steps demonstrate how to use Azure PowerShell Command infrastructure as a service (IaaS) Resource migration from classic deployment model to Azure Resource Manager Deployment model . You can also go through  Az ...

  6. The platform supports from the classic deployment model to Azure Resource Manager Of IaaS Resource migration

    This article describes how to integrate infrastructure as a service (IaaS) Resource migration from classic deployment model to Resource Manager Deployment model . Users can read about  Azure Resource Manager More features and benefits ...

  7. How to migrate the virtual machine under the same cloud service from the classic deployment model to Azure Resource Manager

    Applicable scenario Users want to change all virtual machines under a specific cloud service from the classic deployment model ( hereinafter referred to as :ASM) Migrate to Azure Resource Manager( hereinafter referred to as :ARM). Note If it is used under cloud service VNET Also hope that ...

  8. How to make the same VNET The virtual machine under the model is migrated from the classic deployment model to Azure Resource Manager

    The content of this article is Applicable scenario Solution Applicable scenario Users have multiple cloud services, but in the same VNET Next , We want to take these virtual machines from the classic deployment model ( hereinafter referred to as :ASM) Migrate to Azure Resource Manager( hereinafter referred to as : ...

  9. From the classic deployment model to Azure Resource Manager In depth discussion on the migration technology of

    This article will discuss how to learn from Azure The classic deployment model migrated to Azure Resource Manager Deployment model . This article introduces resources and functional level resources , Let users know Azure How the platform migrates between the two deployment models ...

Random recommendation

  1. iOS Get address book Phone number and name

    // Or import #import <AddressBook/AddressBook.h> - (void)fetchAddressBookBeforeIOS9{ ABAddressBookR ...

  2. zip command reference

    grammar zip [ Parameters ] [ The packaged file name ] [ Packaged directory path ] parameter list -a Convert document to ASCII Pattern -F Try to fix the damaged compressed file -h Show help screen -m After compressing the file , Delete source file -n Specific string , No pressure ...

  3. JAVA - thorough JAVA virtual machine 2

    Two types of class loaders for classes -Java The loader of the virtual machine Root loader (Bootstrap): Use C++ To write ,programer can not abtain this class. Extend the classloader (Ext ...

  4. Use BootStrap The framework sets the global CSS style

    One . Typesetting title HTML All title tags in ,<h1>  To  <h6>  All can use . in addition , It also provides  .h1  To  .h6  class , For inlining (inline) Attribute text gives the title the style . & ...

  5. vue Use a+ router.push When you jump in the form of , The address bar does not display parameters

    terms of settlement : a Don't write links href attribute

  6. reportng Instead of testng The default report for ——pom Set up

    Since it is maven project , Direct attention pom Set up . This article is very clear :maven+testng+reportng Of pom Set up It's important to point out that ,guice Must depend on , Because of this card for most of the day . <dependenc ...

  7. STM32 ------ HardFault_Hander Interrupt function

    1. An array ( Assign values to arrays ) Normal condition , If an array goes out of bounds, it goes into  HardFault_Hander Interrupt the wireless loop of the function . One way to avoid array bounds is : Every time you use an array , Check whether the length of the data to be put is greater than the length of the array , Greater than, then ...

  8. LINUX Performance tools use

    http://xuclv.blog.51cto.com/5503169/1184517

  9. 【bzoj4810】【ynoi2018】 You Nai's corn field

    4810: [Ynoi2017] You Nai's corn field Time Limit: 30 Sec  Memory Limit: 256 MBSubmit: 1090  Solved: 524[Submit][Sta ...

  10. c Language - Student achievement information system

    #include<stdio.h> #define N 100 int Count=0; struct stu { int num; char name[20]; int computer ...