Azure / azure-powershell

Microsoft Azure PowerShell
Other
4.26k stars 3.86k forks source link

New-AzLogicApp connection are not getting created #10911

Closed srinutamada closed 4 years ago

srinutamada commented 4 years ago

I created logic app directly from UI which has connections. I need to use same definition and create few other logic apps in different tenants and with different names. I copied logicapp definition and create few logicapps with New-AzLogicApp command. Apps got created without connections can you please help, how to proceed?

Below is the connection definition that I can see in the actual app, definition

"$connections": { "value": { "servicebus": { "connectionId": "[parameters('connections_servicebus_externalid')]", "connectionName": "servicebus", "id": "/subscriptions/<>/providers/Microsoft.Web/locations/southindia/managedApis/servicebus" }, "sql": { "connectionId": "[parameters('connections_sql_externalid')]", "connectionName": "sql", "id": "/subscriptions/<>/providers/Microsoft.Web/locations/southindia/managedApis/sql" } } }

dingmeng-xue commented 4 years ago

tried below scripts but parameters are not set. No idea how to use -Parameters. Doc is unclear.

$logicapp = Get-AzResource -ResourceGroupName dixue -ResourceType Microsoft.Logic/workflows -ResourceName "xdm-logic"
$a = $logicapp.properties.definition | ConvertTo-Json -Depth 10
$b = $logicapp.properties.parameters | ConvertTo-Json -Depth 10
New-AzLogicApp -ResourceGroupName "dixue" -Name "LogicApp5" -Location westus -Definition $a -Parameters $b
ghost commented 4 years ago

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @mjconnection

ScoutmanPt commented 4 years ago

Howdy guys, I've drilled down for a project in a client u need to do this: 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" }

srinutamada commented 4 years ago

Thanks for your suggestions. I used azure template deployment and it worked.

New-AzResourceGroupDeployment -ResourceGroupName $resourceGroupName -TemplateFile $templatePath -TemplateParameterFile $paramsFilePath