Muokkaa

Jaa


Create a lab plan in Azure Lab Services using PowerShell and the Azure modules

Important

Azure Lab Services will be retired on June 28, 2027. For more information, see the retirement guide.

In this article, you learn how to use PowerShell and the Azure module to create a lab plan. Lab plans are used when creating labs for Azure Lab Services. You'll also add a role assignment so an educator can create labs based on the lab plan. For an overview of Azure Lab Services, see An introduction to Azure Lab Services.

Prerequisites

  • An Azure account with an active subscription. If you don't have an Azure subscription, create a free account before you begin.

Run Connect-AzAccount to sign in to Azure and verify an active subscription.

Create a lab plan

The following steps will show you how to create a lab plan. Any properties set in the lab plan will be used in labs created with this plan.

New-AzResourceGroup -Name "MyResourceGroup" -Location "eastus"

$plan = New-AzLabServicesLabPlan -Name "ContosoLabPlan" `
    -ResourceGroupName "MyResourceGroup" `
    -Location "eastus" `
    -AllowedRegion @("westus","eastus")

Add a user to the Lab Creator role

To create or edit up a lab in the Lab Services web portal (https://labs.azure.com), the educator must be assigned the Lab Creator role. Assigning the Lab Creator role on the lab plan's resource group will allow an educator to use all lab plans in that resource group.

New-AzRoleAssignment -SignInName <emailOrUserprincipalname> `
    -RoleDefinitionName "Lab Creator" `
    -ResourceGroupName "MyResourceGroup"

For more information about role assignments, see Assign Azure roles using Azure PowerShell.

Clean up resources

If you're not going to continue to use this application, delete the lab with the following steps:

Remove-AzRoleAssignment -SignInName <emailOrUserprincipalname> `
    -RoleDefinitionName "Lab Creator" `
    -ResourceGroupName "MyResourceGroup"
$plan | Remove-AzLabServicesLabPlan

Next steps

In this article, you created a resource group and a lab plan. As an admin, you can learn more about Azure PowerShell module and Az.LabServices cmdlets.