Azure CLI 脚本变量给出错误

Azure CLI script variables giving errors

我正在尝试 运行 此处找到的示例脚本:https://docs.microsoft.com/en-au/azure/service-fabric/service-fabric-quickstart-containers-linux#create-a-service-fabric-cluster

#!/bin/bash

# Variables
ResourceGroupName='containertestcluster' 
ClusterName='containertestcluster' 
Location='eastus' 
Password='q6D7nN%6ck@6' 
Subject='containertestcluster.eastus.cloudapp.azure.com' 
VaultName='containertestvault' 
VmPassword='Mypa$$word!321'
VmUserName='sfadminuser'

# Login to Azure and set the subscription
az login

az account set --subscription <mySubscriptionID>

# Create resource group
az group create --name $ResourceGroupName --location $Location 

# Create secure five node Linux cluster. Creates a key vault in a resource group
# and creates a certficate in the key vault. The certificate's subject name must match 
# the domain that you use to access the Service Fabric cluster.  The certificate is downloaded locally.
az sf cluster create --resource-group $ResourceGroupName --location $Location --certificate-output-folder . --certificate-password $Password --certificate-subject-name $Subject --cluster-name $ClusterName --cluster-size 5 --os UbuntuServer1604 --vault-name $VaultName --vault-resource-group $ResourceGroupName --vm-password $VmPassword --vm-user-name $VmUserName

在命令提示符或 PowerShell 中,我 运行“az 登录”并登录,然后我将此脚本复制并粘贴到控制台中,但在涉及变量时出现错误。

我看你用的是Shell脚本,Linux中的运行更合适。对于Windows,PowerShell脚本更合适。而在Windows中,变量需要这样设置:

$varName = 'xxxx'

因此您需要像上面那样更改所有变量。我建议您将脚本更改为 PowerShell 脚本。