2

I am new to Logic Apps so this might be a very basic question.

Here is what I have done,

I have created a very basic Logic App which will trigger when a new item is created in SharePoint List and send an email.

Logic App creates JSON file behind the scene and when I looked at it I can see the list name is not mentioned but list id is being captured.

If I deploy this via the PowerShell to the next environment(TEST/PROD) this will not work.

So my question is how can I update my logic so that it will work with next environment(TEST/PROD)

Updated on 2/13

So based on feedback I have updated trigger path from hard code value to the parameterized value

OLD

  "triggers": {
    "When_a_file_is_created_or_modified_(properties_only)": {
      "type": "ApiConnection",
      "inputs": {
        "host": {
          "connection": {
            "name": "@parameters('$connections')['sharepointonline']['connectionId']"
          }
        },
        "method": "get",
        "path": "path": "/datasets/@{encodeURIComponent(encodeURIComponent('https://orgname.sharepoint.com/sites/mysite'))}/tables/@{encodeURIComponent(encodeURIComponent('7c7e9f92-5705-462a-9bfb-28985e4fa5b6'))}/onupdatedfileitems"
      },
      "recurrence": {
        "frequency": "Hour",
        "interval": 1
      },
      "splitOn": "@triggerBody()?['value']"
    }

NEW

  "triggers": {
    "When_a_file_is_created_or_modified_(properties_only)": {
      "type": "ApiConnection",
      "inputs": {
        "host": {
          "connection": {
            "name": "@parameters('$connections')['sharepointonline']['connectionId']"
          }
        },
        "method": "get",
        "path": "/datasets/@{encodeURIComponent(encodeURIComponent([parameters('SiteUrl')]))}/tables/@{encodeURIComponent(encodeURIComponent([parameters('LibraryId')]))}/onupdatedfileitems"
      },
      "recurrence": {
        "frequency": "Hour",
        "interval": 1
      },
      "splitOn": "@triggerBody()?['value']"
    }

After I made this change got below error in deployment.

"error": {
  "code": "InvalidTemplate",
  "message": "The template validation failed: 'The template trigger 'When_a_file_is_created_or_modified_(properties_only)' at line '1' and column '280' is not valid: \"Unable to parse template language expression 'encodeURIComponent(encodeURIComponent([parameters('SiteUrl')]))': expected token 'Identifier' and actual 'LeftSquareBracket'.\".'."
}
1
  • Make sure you understand the difference between ARM Template parameters and LogicApp parameters. It appears you nested an ARM template parameter inside a logic App expression. See this article for how you need to either build a template level concatenation or pass an ARM parameter into a template one: platform.deloitte.com.au/articles/…
    – willman
    Commented Feb 13, 2020 at 23:28

3 Answers 3

0

We can do it by exporting and importing the logic app - but before need to ensure, we have all required list /library in the target environment.

Here are the steps to Export and Import the logic app :

Assume that we have created a Microsoft Flow.

  • On the top right corner of the flow , click on the Settings->Export->Logic Apps Template(.json)

  • Download the JSON file in the disk.

  • Login to https://portal.azure.comwith valid azure credential.

    Create a separate Resource Group. (This is not mandatory. But it

    will be easy for us to cleanup the tenant). I have created a

    Resource Group called “FlowDemo”

  • Click on Create a resource on the top left hand side.

  • Search for “Template Deployment” on the search box.

  • Click on Create.

  • Click on “Build your own template in the editor”

  • The template will be shown as below.

  • Click on “Load File” and select the json file which we exported from flow.

  • The data from the json will be loaded here.

  • Click on Save

  • Select the resource group and the name appropriately.

  • Click on the “I agree” on the Terms and conditions as usual without

  • reading the terms and conditions. ( J Just kidding)

  • Click on Purchase.

  • Once the deployment succeeds, we can see the Logic App got created under the resource group “Flow Demo”

  • The flow which we created will imported here with broken connections.

  • We need to establish the connections once again here and the flow is ready to use as a Logic App.

  • After establishing the connections, the Logic App will look as below.

Now, save the flow and execute it.

Reference URL :

Step By Step Procedure To Export A Microsoft Flow As JSON And Import As Logic App In Azure

1
  • Thanks for the detailed response. But my question remains the same when you export it will capture list id in JSON file. Upon import same id remains(See step#11 in your blog). The whole purpose of export-import is to move your flow from DEV to UAT or UAT to PROD. During this process, we need to change the site URL as well as the GUID of the list. I am not sure how we can do this process. Commented Jan 31, 2020 at 13:49
0

If you built your Logic App directly in the Designer in the Azure Portal, then you will need to start by downloading the generated Logic App ARM Template so it can be managed in Visual Studio. Obviously, if you've already built your Logic App in Visual Studio, you can skip to the next step.

You need to build Parameters into your ARM Template. This will give you the basics, this will give you a more advanced strategy.

1
  • Thanks for help @willman. Based on your input I have updated my question and got an error. Please see my updated question for more details. Commented Feb 13, 2020 at 19:48
0

I just stumbled upon this thread while trying to automate this kind of Deployment and finally figured out how.

@Ravi Khambati - You were very close and all you needed to do was remove "[]" surrounding parameters

  "triggers": {
"When_a_file_is_created_or_modified_(properties_only)": {
  "type": "ApiConnection",
  "inputs": {
    "host": {
      "connection": {
        "name": "@parameters('$connections')['sharepointonline']['connectionId']"
      }
    },
    "method": "get",
    "path": "/datasets/@{encodeURIComponent(encodeURIComponent(parameters('SiteUrl')))}/tables/@{encodeURIComponent(encodeURIComponent(parameters('LibraryId')))}/onupdatedfileitems"
  },
  "recurrence": {
    "frequency": "Hour",
    "interval": 1
  },
  "splitOn": "@triggerBody()?['value']"
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.