使用 Azure CLI 创建托管应用程序定义

此脚本会将托管应用程序定义发布到服务目录。

若要运行此示例,请安装最新版本的 Azure CLI。 若要开始,请运行 az login 以创建与 Azure 的连接。

适用于 Azure CLI 的示例是针对 bash shell 编写的。 若要在 Windows PowerShell 或命令提示符中运行此示例,可能需要更改脚本的元素。

如果没有 Azure 订阅,可在开始前创建一个试用帐户

示例脚本

#!/bin/bash

# Create resource group
az group create --name appDefinitionGroup --location chinaeast

# Get Azure Active Directory group to manage the application
groupid=$(az ad group show --group appManagers --query objectId --output tsv)

# Get role
roleid=$(az role definition list --name Owner --query [].name --output tsv)

# Create the definition for a managed application
az managedapp definition create \
  --name "ManagedStorage" \
  --location "chinaeast" \
  --resource-group appDefinitionGroup \
  --lock-level ReadOnly \
  --display-name "Managed Storage Account" \
  --description "Managed Azure Storage Account" \
  --authorizations "$groupid:$roleid" \
  --package-file-uri "https://raw.githubusercontent.com/Azure/azure-managedapp-samples/master/Managed%20Application%20Sample%20Packages/201-managed-storage-account/managedstorage.zip"

脚本说明

此脚本使用以下命令创建托管应用程序定义。 表中的每条命令链接到特定于命令的文档。

命令 说明
az managedapp definition create 创建托管应用程序定义。 提供包含所需文件的包。

后续步骤