MicrosoftDocs / azure-docs

Open source documentation of Microsoft Azure
https://docs.microsoft.com/azure
Creative Commons Attribution 4.0 International
10.24k stars 21.41k forks source link

ARM Condition Deploy Logic APP Eroor #101890

Closed myob-hankun closed 1 year ago

myob-hankun commented 1 year ago

Hi Team,

I used conditions to deploy the logic app, but it always has an error, because it will create the trigger, this trigger depends on the logic app, but the condition is false, so the logic app does not exist.

If the condition is false, the logic app is not created, but its triggers still seem to be created.

Could you help me? I would like to disable logic app and its trigger if the condition is false

{
  "condition": "[equals(parameters('appEnvironment'),'PROD')]",
"type": "Microsoft.Logic/workflows",
"apiVersion": "2017-07-01",
"name": "[parameters('criticalAlertLogicAppName')]",
"location": "[parameters('siteLocation')]",
"properties": {
  "state": "Enabled",
  "definition": {
    "$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
      "$connections": {
        "defaultValue": {},
        "type": "Object"
      }
    },
    "triggers": {
      "manual": {
        "type": "Request",
        "kind": "Http",
        "inputs": {
          "schema": {
            "properties": {
              "data": {
                "properties": {
                  "alertContext": {
                    "properties": {},
                    "type": "object"
                  },
                  "essentials": {
                    "properties": {
                      "alertContextVersion": {
                        "type": "string"
                      },
                      "alertId": {
                        "type": "string"
                      },
                      "alertRule": {
                        "type": "string"
                      },
                      "alertTargetIDs": {
                        "items": {
                          "type": "string"
                        },
                        "type": "array"
                      },
                      "description": {
                        "type": "string"
                      },
                      "essentialsVersion": {
                        "type": "string"
                      },
                      "firedDateTime": {
                        "type": "string"
                      },
                      "monitorCondition": {
                        "type": "string"
                      },
                      "monitoringService": {
                        "type": "string"
                      },
                      "originAlertId": {
                        "type": "string"
                      },
                      "resolvedDateTime": {
                        "type": "string"
                      },
                      "severity": {
                        "type": "string"
                      },
                      "signalType": {
                        "type": "string"
                      }
                    },
                    "type": "object"
                  }
                },
                "type": "object"
              },
              "schemaId": {
                "type": "string"
              }
            },
            "type": "object"
          }
        }
      }
    },
    "actions": {
      "Send-critical-alert-to-slack": {
        "runAfter": {},
        "type": "ApiConnection",
        "inputs": {
          "body": {
            "channel": "[parameters('criticalAlertSlackChannel')]",
            "text": ">:azure:  *Azure Alert Notification*  @{if(equals('Resolved', triggerBody()?['data']?['essentials']?['monitorCondition']), ':done-:', ':red-alert:')}\n> \n>*Subject: * Alert  *@{triggerBody()?['data']?['essentials']?['alertRule']}* with severity  *@{triggerBody()?['data']?['essentials']?['severity']}*  has condition *@{triggerBody()?['data']?['essentials']?['monitorCondition']}*\n>\n>*Alert id:*\n> @{triggerBody()?['data']?['essentials']?['alertId']}\n>\n>*Description:*  @{triggerBody()?['data']?['essentials']?['description']}\n>\n>*Date fired: * @{triggerBody()?['data']?['essentials']?['firedDateTime']}\n>\n>*Affected resource: * @{triggerBody()?['data']?['essentials']?['alertTargetIDs']}"
          },
          "host": {
            "connection": {
              "name": "@parameters('$connections')['slack']['connectionId']"
            }
          },
          "method": "post",
          "path": "/v2/chat.postMessage"
        }
      }
    }
  },
  "parameters": {
    "$connections": {
      "value": {
        "slack": {
          "id": "[subscriptionResourceId('Microsoft.Web/locations/managedApis', parameters('siteLocation'), 'slack')]",
          "connectionId": "[resourceId(parameters('resourceGroupName'), 'Microsoft.Web/connections', parameters('connectionsSlackName'))]",
          "connectionName": "[parameters('connectionsSlackName')]"
        }
      }
    }
  }
},
"dependsOn": [
  "[resourceId('Microsoft.Web/connections', parameters('connectionsSlackName'))]"
]
},

Document Details

Do not edit this section. It is required for learn.microsoft.com ➟ GitHub issue linking.

YashikaTyagii commented 1 year ago

@myob-hankun It would be great if you could add a link to the documentation you are following for these steps? This would help us redirect the issue to the appropriate team. Thanks!!

myob-hankun commented 1 year ago

https://learn.microsoft.com/en-us/azure/azure-resource-manager/templates/template-tutorial-use-conditions

YashikaTyagii commented 1 year ago

@myob-hankun Thanks for your feedback! We will investigate and update as appropriate.

myob-hankun commented 1 year ago

Hi Team, Any updates?

MonikaReddy-MSFT commented 1 year ago

@myob-hankun - We are currently looking into it and I will get back to you as soon as possible. Thank you for your patience.

mumian commented 1 year ago

@myob-hankun - what is the error that you are getting? Is it a schema validation error or a runtime error? When you say the condition is false, do you mean appEnvironment is not equal to 'PROD'? It doesn't quite make sense to me why the trigger is created when the condition is false.

myob-hankun commented 1 year ago

Hi @mumian , it's a runtime error, the appEnvironment is SIT, so the condition is false. The Logic APP was not created, but Azure wants to generate its trigger. Because the Logic APP has not existed, and the trigger depends on the Logic APP. The result is trigger is created failure.

mumian commented 1 year ago

@myob-hankun - thank you for providing the details. We only answer content related questions here. This might be related to the Azure Logic service. You might want to ask the Azure forum or open a support ticket. We have an Azure Logic content developer. She is currently OOF. I can check with her next week.

MonikaReddy-MSFT commented 1 year ago

@mumian - Thank you for providing your insights. @myob-hankun - I hope @mumian has answered your question. At this moment, Since there is no doc update required, We will now proceed to close this thread. If there are further questions regarding this matter, please tag me in your reply. We will gladly continue the discussion and we will reopen the issue.