我们如何 运行 Azure Bash 中的多个 CLI 命令一起使用?

How can we run multiple CLI command in Azure Bash together?

我有多个资源要一起使用 CLI 命令部署到我的环境中。例如:我需要使用单个脚本创建 VM、Web 应用程序、Redis 缓存等。 我们可以一起创建所有资源,而不是创建单独的资源。

一种方法是将所有命令放在 .sh shell 脚本中。以下是如何执行此操作的示例:

#!/bin/bash

az group create -n MyResourceGroup -l centralus

az vm create -n MyVm -g MyResourceGroup --image UbuntuLTS

az webapp create -g MyResourceGroup -p MyPlan -n MyUniqueAppName

# More Azure CLI commands to create resources

然后您可以 运行 您的本地环境中的脚本 bash shell 或 Azure Cloud Shell 像这样:

username@Azure:~$ ./script.sh

另一种方法是使用 ARM template 来部署您的资源。