Koolitus
Moodul
Control and organize Azure resources with Azure Resource Manager - Training
Use Azure Resource Manager to organize resources, enforce standards, and protect critical assets from deletion.
Seda brauserit enam ei toetata.
Uusimate funktsioonide, turbevärskenduste ja tehnilise toe kasutamiseks võtke kasutusele Microsoft Edge.
By default, Azure DevTest Labs creates a new resource group whenever a new virtual machine is created. As a lab owner, you can configure your lab virtual machines to be created in a specific resource group. This feature helps you in the following scenarios:
With this feature, you can use a script to specify a new or existing resource group within your Azure subscription for all your lab VMs. Currently, Azure DevTest Labs supports this feature through an API.
Märkus
All subscription limits apply when you create labs in DevTest Labs. Think of a lab as any other resource in your subscription. In case of resource groups, the limit is 980 resource groups per subscription.
Follow these steps to specify a resource group for all VMs created in the lab.
Sign in to the Azure portal.
Select All Services on the left navigational menu.
Select DevTest Labs from the list.
From the list of labs, select your lab.
Select Configuration and policies in the Settings section on the left menu.
Select Lab settings on the left menu.
Select All virtual machines in one resource group.
Select an existing resource group in the drop-down list (or) select Create new, enter a name for the resource group, and select OK.
The following example shows how to use a PowerShell script to create all lab virtual machines in a new resource group.
[CmdletBinding()]
Param(
$subId,
$labRg,
$labName,
$vmRg
)
az login | out-null
az account set --subscription $subId | out-null
$rgId = "/subscriptions/"+$subId+"/resourceGroups/"+$vmRg
"Updating lab '$labName' with vm rg '$rgId'..."
az resource update -g $labRg -n $labName --resource-type "Microsoft.DevTestLab/labs" --api-version 2018-10-15-preview --set properties.vmCreationResourceGroupId=$rgId
"Done. New virtual machines will now be created in the resource group '$vmRg'."
Invoke the script by using the following command. ResourceGroup.ps1 is the file that contains the preceding script:
.\ResourceGroup.ps1 -subId <subscriptionID> -labRg <labRGNAme> -labName <LanName> -vmRg <RGName>
If you're using an Azure Resource Manager template to create a lab, use the vmCreationResourceGroupId property in the lab properties section of your template, as shown in the following example:
{
"type": "microsoft.devtestlab/labs",
"name": "[parameters('lab_name')]",
"apiVersion": "2018-10-15-preview",
"location": "eastus",
"tags": {},
"scale": null,
"properties": {
"vmCreationResourceGroupId": "/subscriptions/<SubscriptionID>/resourcegroups/<ResourceGroupName>",
"labStorageType": "Premium",
"premiumDataDisks": "Disabled",
"provisioningState": "Succeeded",
"uniqueIdentifier": "000000000f-0000-0000-0000-00000000000000"
},
"dependsOn": []
},
You have the following options as a lab owner when using this API:
This setting applies to new virtual machines created in the lab. The older VMs in your lab that were created in their own resource groups remain unaffected. Environments that are created in your lab continue to remain in their own resource groups.
How to use this API:
/subscriptions/<SubscriptionID>/resourceGroups/<ResourceGroupName>
. Ensure that the resource group is in the same subscription as the lab.See the following article:
Koolitus
Moodul
Control and organize Azure resources with Azure Resource Manager - Training
Use Azure Resource Manager to organize resources, enforce standards, and protect critical assets from deletion.