Search code examples
azurepowershellazure-logic-appsazure-powershellpowershell-4.0

How to set azure logic app definition using powershell


I'm trying to set the definition of the logic app using powershell, this is the line I'm using:

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\":{}}"

I took the definition from the logic app itself and converted it to JSON using an online tool, I'm getting this result:

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

I'm assuming the definition format is wrong, how can I pass a correct one?


Solution

  • Just use the commands below.

    $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
    

    enter image description here

    And you should note the last parameters in your command belongs to -Parameters parameter, you need to use it instead of -Definition.