使用 PowerShell 创建托管应用程序定义Create a managed application definition with PowerShell

此脚本会将托管应用程序定义发布到服务目录。This script publishes a managed application definition to a service catalog.

如果没有 Azure 订阅,可在开始前创建一个试用帐户If you don't have an Azure subscription, create a trial account before you begin.

示例脚本Sample script

备注

本文进行了更新,以便使用新的 Azure PowerShell Az 模块。This article has been updated to use the new Azure PowerShell Az module. 你仍然可以使用 AzureRM 模块,至少在 2020 年 12 月之前,它将继续接收 bug 修补程序。You can still use the AzureRM module, which will continue to receive bug fixes until at least December 2020. 若要详细了解新的 Az 模块和 AzureRM 兼容性,请参阅新 Azure Powershell Az 模块简介To learn more about the new Az module and AzureRM compatibility, see Introducing the new Azure PowerShell Az module. 有关 Az 模块安装说明,请参阅安装 Azure PowerShellFor Az module installation instructions, see Install Azure PowerShell.

# Create resource group
New-AzResourceGroup -Name appDefinitionGroup -Location chinaeast

# Get Azure Active Directory group to manage the application
$groupid=(Get-AzADGroup -SearchString appManagers).Id

# Get role
$roleid=(Get-AzRoleDefinition -Name Owner).Id

# Create the definition for a managed application
New-AzManagedApplicationDefinition `
  -Name "ManagedStorage" `
  -Location "chinaeast" `
  -ResourceGroupName appDefinitionGroup `
  -LockLevel ReadOnly `
  -DisplayName "Managed Storage Account" `
  -Description "Managed Az.Storage Account" `
  -Authorization "${groupid}:$roleid" `
  -PackageFileUri "https://raw.githubusercontent.com/Azure/azure-managedapp-samples/master/samples/201-managed-storage-account/managedstorage.zip"

脚本说明Script explanation

此脚本使用以下命令创建托管应用程序定义。This script uses the following command to create the managed application definition. 表中的每条命令均链接到特定于命令的文档。Each command in the table links to command-specific documentation.

CommandCommand 说明Notes
New-AzManagedApplicationDefinitionNew-AzManagedApplicationDefinition 创建托管应用程序定义。Create a managed application definition. 提供包含所需文件的包。Provide the package that contains the required files.

后续步骤Next steps