如何使用powershell设置azure逻辑应用程序定义

如何使用powershell设置azure逻辑应用程序定义,azure,powershell,azure-logic-apps,azure-powershell,powershell-4.0,Azure,Powershell,Azure Logic Apps,Azure Powershell,Powershell 4.0,我正在尝试使用powershell设置逻辑应用程序的定义,这是我正在使用的行: Set-AzLogicApp -ResourceGroupName "dummy-dev-rg" -ResourceName "dummy-la-d" -Definition "{\"definition\":{\"$schema\":\"https:\/\/schema.management.azure.com\/p

我正在尝试使用powershell设置逻辑应用程序的定义,这是我正在使用的行:

Set-AzLogicApp -ResourceGroupName "dummy-dev-rg" -ResourceName "dummy-la-d" -Definition "{\"definition\":{\"$schema\":\"https:\/\/schema.management.azure.com\/providers\/Microsoft.Logic\/schemas\/2016-06-01\/workflowdefinition.json#\",\"actions\":{},\"contentVersion\":\"1.0.0.0\",\"outputs\":{},\"parameters\":{},\"triggers\":{}},\"parameters\":{}}"
我从logic应用程序本身获取定义,并使用在线工具将其转换为JSON,得到以下结果:

A positional parameter cannot be found that accepts argument 'definition\:{\\:\https:\/\/schema.management.azure.com\/providers\/Microsoft.Logic\/schemas\/2016-06-01\/workfl
    owdefinition.json#\,\actions\:{},\contentVersion\:\1.0.0.0\,\outputs\:{},\parameters\:{},\triggers\:{}},\parameters\:{}}'.
    At line:1 char:1

我假设定义格式错误,如何传递正确的格式?

只需使用下面的命令即可

$json = '{
"$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
"actions": {},
"contentVersion": "1.0.0.0",
"outputs": {},
"parameters": {},
"triggers": {}
}'

Set-AzLogicApp -ResourceGroupName xxxx -ResourceName joylogic -Definition $json


您应该注意命令中最后一个
参数
属于
-parameters
参数,您需要使用它而不是
-Definition

您只需要正确地转义字符串。由于使用双引号将同时包含双引号的字符串括起来,因此会出现错误。您需要在字符串中的所有双引号前面加一个反勾号,或者将字符串中的所有双引号加倍,以转义字符串中的所有双引号。或者,在您的情况下,最简单的选择是删除周围的双引号,改为使用单引号,因此不需要转义。请参阅: