如何将逻辑应用程序的工作流定义获取为 JSON?
How can I get the workflow definition of a logic app as JSON?
如何获取逻辑应用程序的工作流定义 JSON?
我可以使用 New-AzLogicApp 命令从 JSON 定义文件创建新的逻辑应用程序
但我看不到如何反转该过程,即获取现有逻辑应用程序的 JSON 定义。
我试过 Get-AzLogicApp which returns a Workflow 对象。
但我在最后一步受阻,即从工作流程返回到实际的 JSON 文件
您可以使用 REST API
获取详细信息。
休息 Api Documentation
或者您可以尝试使用 Get-AzLogicApp | ConvertFrom-Json | ConvertTo-Json
看看是否有帮助
如果要获取逻辑应用程序的定义,请尝试以下命令。
$logicapp = Get-AzResource -ResourceGroupName <ResourceGroupName> -ResourceType Microsoft.Logic/workflows -ResourceName "<logic app name>"
$logicapp.properties.definition | ConvertTo-Json
如果你想把它作为一个 .json
文件,只需要改变第二行如下。
$logicapp.properties.definition | ConvertTo-Json | Out-File "C:\Users\joyw\Desktop\logic.json"
更新:
您可以将ConvertTo-Json
的-Depth
参数指定为3
,如果您希望在JSON表示中包含更多层次的包含对象,您也可以用其他值指定它。
-Depth
Specifies how many levels of contained objects are included in the JSON representation. The default value is 2.
$logicapp.properties.definition | ConvertTo-Json -Depth 3
我已经深入研究了一个客户的项目,您需要这样做:
1 )Get-AzLogicApp
$lapp.Definition.ToString()-> this is the entire definition of the logicapp
2) Save the definition to a file
3) Use New-AzLogicApp or Set-AzLogicApp with -DefinitionFilePath pointing to that file
$a= New-AzLogicApp -ResourceGroupName $rg -name $name1 -location $loc -DefinitionFilePath $fileName1 -ParameterFilePath $parm1
$a.Parameters.Count
*for Parameters i use this content in a file
{
"$connections": {
"value": {
"office365": {
"connectionId": "/subscriptions/SUBS-DEPLOY/resourceGroups/RG-DEPLOY/providers/Microsoft.Web/connections/office365",
"connectionName": "office365",
"id": "/subscriptions/SUBS-DEPLOY/providers/Microsoft.Web/locations/westeurope/managedApis/office365"
},
"sharepointonline": {
"connectionId": "/subscriptions/SUBS-DEPLOY/resourceGroups/RG-DEPLOY/providers/Microsoft.Web/connections/sharepointonline",
"connectionName": "sharepointonline",
"id": "/subscriptions/SUBS-DEPLOY/providers/Microsoft.Web/locations/westeurope/managedApis/sharepointonline"
}
}
}
}
replace SUBS-DEPLOY with the subscription id and RG-DEPLOY with resource group name and all good.
Anything just buzz: stationsolutions_at_gmail.com
Hope it helps
Here's the code ..
function Get-LogicApp($resourceGroupName ,$location,$name)
{
Write-Host " Get LogicApp Definition $name"
$lapp = Get-AzLogicApp -ResourceGroupName $resourceGroupName -Name $name
$o= $lapp.Definition.ToString()
$fileName = "..\logicapps\" + $name + ".logicapp.json"
$o | Out-File -FilePath $fileName
$parms = "..\logicapps\templates\parms.json"
$fileName = "..\logicapps\" + $name + ".logicapp.parms.json"
Copy-Item -Path $parms $fileName
Write-Host " LogicApp Definition $resourceGroupName > $fileName"
}
如何获取逻辑应用程序的工作流定义 JSON?
我可以使用 New-AzLogicApp 命令从 JSON 定义文件创建新的逻辑应用程序
但我看不到如何反转该过程,即获取现有逻辑应用程序的 JSON 定义。
我试过 Get-AzLogicApp which returns a Workflow 对象。
但我在最后一步受阻,即从工作流程返回到实际的 JSON 文件
您可以使用 REST API
获取详细信息。
休息 Api Documentation
或者您可以尝试使用 Get-AzLogicApp | ConvertFrom-Json | ConvertTo-Json
看看是否有帮助
如果要获取逻辑应用程序的定义,请尝试以下命令。
$logicapp = Get-AzResource -ResourceGroupName <ResourceGroupName> -ResourceType Microsoft.Logic/workflows -ResourceName "<logic app name>"
$logicapp.properties.definition | ConvertTo-Json
如果你想把它作为一个 .json
文件,只需要改变第二行如下。
$logicapp.properties.definition | ConvertTo-Json | Out-File "C:\Users\joyw\Desktop\logic.json"
更新:
您可以将ConvertTo-Json
的-Depth
参数指定为3
,如果您希望在JSON表示中包含更多层次的包含对象,您也可以用其他值指定它。
-Depth
Specifies how many levels of contained objects are included in the JSON representation. The default value is 2.
$logicapp.properties.definition | ConvertTo-Json -Depth 3
我已经深入研究了一个客户的项目,您需要这样做:
1 )Get-AzLogicApp
$lapp.Definition.ToString()-> this is the entire definition of the logicapp
2) Save the definition to a file
3) Use New-AzLogicApp or Set-AzLogicApp with -DefinitionFilePath pointing to that file
$a= New-AzLogicApp -ResourceGroupName $rg -name $name1 -location $loc -DefinitionFilePath $fileName1 -ParameterFilePath $parm1
$a.Parameters.Count
*for Parameters i use this content in a file
{
"$connections": {
"value": {
"office365": {
"connectionId": "/subscriptions/SUBS-DEPLOY/resourceGroups/RG-DEPLOY/providers/Microsoft.Web/connections/office365",
"connectionName": "office365",
"id": "/subscriptions/SUBS-DEPLOY/providers/Microsoft.Web/locations/westeurope/managedApis/office365"
},
"sharepointonline": {
"connectionId": "/subscriptions/SUBS-DEPLOY/resourceGroups/RG-DEPLOY/providers/Microsoft.Web/connections/sharepointonline",
"connectionName": "sharepointonline",
"id": "/subscriptions/SUBS-DEPLOY/providers/Microsoft.Web/locations/westeurope/managedApis/sharepointonline"
}
}
}
}
replace SUBS-DEPLOY with the subscription id and RG-DEPLOY with resource group name and all good.
Anything just buzz: stationsolutions_at_gmail.com
Hope it helps
Here's the code ..
function Get-LogicApp($resourceGroupName ,$location,$name)
{
Write-Host " Get LogicApp Definition $name"
$lapp = Get-AzLogicApp -ResourceGroupName $resourceGroupName -Name $name
$o= $lapp.Definition.ToString()
$fileName = "..\logicapps\" + $name + ".logicapp.json"
$o | Out-File -FilePath $fileName
$parms = "..\logicapps\templates\parms.json"
$fileName = "..\logicapps\" + $name + ".logicapp.parms.json"
Copy-Item -Path $parms $fileName
Write-Host " LogicApp Definition $resourceGroupName > $fileName"
}