使用 PowerShell 为服务目录部署托管应用程序Deploy a managed application for a service catalog with PowerShell

此脚本从服务目录部署托管应用程序定义。This script deploys a managed application definition from the 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 applicationGroup -Location chinaeast

# Get ID of managed application definition
$appid=(Get-AzManagedApplicationDefinition -ResourceGroupName appDefinitionGroup -Name ManagedStorage).ManagedApplicationDefinitionId

# Create the managed application
New-AzManagedApplication `
  -Name storageApp `
  -Location chinaeast `
  -Kind ServiceCatalog `
  -ResourceGroupName applicationGroup `
  -ManagedApplicationDefinitionId $appid `
  -ManagedResourceGroupName "InfrastructureGroup" `
  -Parameter "{`"storageAccountNamePrefix`": {`"value`": `"demostorage`"}, `"storageAccountType`": {`"value`": `"Standard_LRS`"}}"

脚本说明Script explanation

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

CommandCommand 说明Notes
New-AzManagedApplicationNew-AzManagedApplication 创建托管应用程序。Create a managed application. 提供模板的定义 ID 和参数。Provide the definition ID and parameters for the template.

后续步骤Next steps