Azure CLI 2:如何在z组部署create命令中提供参数? [英] Azure CLI 2: how to provide parameters in az group deployment create command?

查看:47
本文介绍了Azure CLI 2:如何在z组部署create命令中提供参数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在Windows计算机上使用Azure CLI 2.0,并且尝试使用

I am using Azure CLI 2.0 on a windows machine and I am trying to create a Docker VM using this Microsoft documentation:

az group deployment create --resource-group myResourceGroup \
  --parameters '{"newStorageAccountName": {"value": "mystorageaccount"},
    "adminUsername": {"value": "azureuser"},
    "adminPassword": {"value": "P@ssw0rd!"},
    "dnsNameForPublicIP": {"value": "mypublicdns"}}' \
--template-uri https://raw.githubusercontent.com/Azure/azure-quickstart-templates/master/docker-simple-on-ubuntu/azuredeploy.json

将所有内容放在一行中会导致无法识别的参数"错误.用双引号替换参数单引号会导致期望属性名称用双引号引起来"错误,而删除参数选项会产生预期的部署模板验证失败"错误.提供参数值的正确方法是什么?

Putting everything in one line results in an "unrecognized arguments" error. Replacing the parameter single quotes by double quotes results in an "Expecting property name enclosed in double quotes" error and removing the parameters option gives an expected "Deployment template validation failed" error. What is the correct way to provide the parameter value?

推荐答案

请尝试以下脚本:

az group deployment create --resource-group jason --parameters "{\"newStorageAccountName\": {\"value\": \"jasondisks321\"},\"adminUsername\": {\"value\": \"jason\"},\"adminPassword\": {\"value\": \"122130869@qq\"},\"dnsNameForPublicIP\": {\"value\": \"jasontest321\"}}" --template-uri https://raw.githubusercontent.com/Azure/azure-quickstart-templates/master/docker-simple-on-ubuntu/azuredeploy.json

对我有用.

在cli 2.0中,我们可以使用-help 查找命令help:

In cli 2.0, we can use --help to find the command help:

C:\windows\system32>az group deployment create --help

Examples
    Create a deployment from a remote template file.
        az group deployment create -g MyResourceGroup --template-uri
        https://myresource/azuredeploy.json --parameters @myparameters.json

    Create a deployment from a local template file and use parameter values in a string.
        az group deployment create -g MyResourceGroup --template-file azuredeploy.json --parameters
        "{\"location\": {\"value\": \"westus\"}}"

这篇关于Azure CLI 2:如何在z组部署create命令中提供参数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆