can you describe about azure logic app.

chandar 0 Reputation points
2024-04-22T11:40:57.5266667+00:00

azure logic app using sharepoint data

Azure Logic Apps
Azure Logic Apps
An Azure service that automates the access and use of data across clouds without writing code.
2,855 questions
{count} votes

1 answer

Sort by: Most helpful
  1. SwathiDhanwada-MSFT 17,636 Reputation points
    2024-04-23T16:47:14.62+00:00

    @chandar Thanks for reaching out. Here are some of the references for you on getting started with integrating SharePoint and logic apps.

    Here is a sample example of using azure logic apps for sharepoint.

    • First, you need to create a connection between Azure Logic App and SharePoint. To do this, go to the Azure portal and navigate to the Logic App that you want to use. Click on the "Logic App Designer" tab and then click on the "New step" button. Select "Add a connection" and then select "SharePoint". Follow the prompts to sign in to your SharePoint account and create the connection.
    • Once you have created the connection, you can add a trigger to your Logic App. Select the "When an item is created or modified" trigger and then enter the Site Address and List Name for the SharePoint site and list that you want to monitor. If you don't know the Site Address and List Name, you can find them by navigating to the SharePoint site and list in your web browser and copying the URL. The workflow is triggered when a new item is created in a SharePoint list.
    • Retrieves the attachments of the new item using the "Get_attachments" action.
    • Loops through each attachment using the "For_each" action.
    • For each attachment, the workflow retrieves its content using the "Get_attachment_content" action.
    • Send an email using the "Send_an_email_(V2)" action, with the attachment added to the email as an attachment and the email body and subject specified in the action.
    • Finally, save and run your Logic App to test it.

    Screenshot of Logic app:

    User's image

    Sample code reference:

    {
        "definition": {
            "$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
            "actions": {
                "For_each": {
                    "actions": {
                        "Get_attachment_content": {
                            "inputs": {
                                "host": {
                                    "connection": {
                                        "name": "@parameters('$connections')['sharepointonline']['connectionId']"
                                    }
                                },
                                "method": "get",
                                "path": "/datasets/@{encodeURIComponent(encodeURIComponent('https://microsoftapc.sharepoint.com/teams/SampleSharepoint'))}/tables/@{encodeURIComponent(encodeURIComponent('xxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'))}/items/@{encodeURIComponent(encodeURIComponent(items('For_each')?['Id']))}/attachments/@{encodeURIComponent(items('For_each')?['Id'])}/$value"
                            },
                            "type": "ApiConnection"
                        },
                        "Send_an_email_(V2)_copy": {
                            "inputs": {
                                "body": {
                                    "Attachments": [
                                        {
                                            "ContentBytes": "@{base64(body('Get_attachment_content'))}",
                                            "Name": "@{items('For_each')?['DisplayName']}"
                                        }
                                    ],
                                    "Body": "<p>tette</p>",
                                    "Subject": "SharePoint : New Item has been added",
                                    "To": "xxxxxxx@microsoft.com"
                                },
                                "host": {
                                    "connection": {
                                        "name": "@parameters('$connections')['outlook']['connectionId']"
                                    }
                                },
                                "method": "post",
                                "path": "/v2/Mail"
                            },
                            "runAfter": {
                                "Get_attachment_content": [
                                    "Succeeded"
                                ]
                            },
                            "type": "ApiConnection"
                        }
                    },
                    "foreach": "@body('Get_attachments')",
                    "runAfter": {
                        "Get_attachments": [
                            "Succeeded"
                        ]
                    },
                    "type": "Foreach"
                },
                "Get_attachments": {
                    "inputs": {
                        "host": {
                            "connection": {
                                "name": "@parameters('$connections')['sharepointonline']['connectionId']"
                            }
                        },
                        "method": "get",
                        "path": "/datasets/@{encodeURIComponent(encodeURIComponent('https://microsoftapc.sharepoint.com/teams/SampleSharepoint'))}/tables/@{encodeURIComponent(encodeURIComponent('xxxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'))}/items/@{encodeURIComponent(encodeURIComponent(triggerBody()?['ID']))}/attachments"
                    },
                    "runAfter": {},
                    "type": "ApiConnection"
                }
            },
            "contentVersion": "1.0.0.0",
            "outputs": {},
            "parameters": {
                "$connections": {
                    "defaultValue": {},
                    "type": "Object"
                }
            },
            "triggers": {
                "When_an_item_is_created": {
                    "evaluatedRecurrence": {
                        "frequency": "Second",
                        "interval": 3
                    },
                    "inputs": {
                        "host": {
                            "connection": {
                                "name": "@parameters('$connections')['sharepointonline']['connectionId']"
                            }
                        },
                        "method": "get",
                        "path": "/datasets/@{encodeURIComponent(encodeURIComponent('https://microsoftapc.sharepoint.com/teams/SampleSharepoint/'))}/tables/@{encodeURIComponent(encodeURIComponent('xxxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'))}/onnewitems"
                    },
                    "recurrence": {
                        "frequency": "Second",
                        "interval": 3
                    },
                    "splitOn": "@triggerBody()?['value']",
                    "type": "ApiConnection"
                }
            }
        },
        "parameters": {
            "$connections": {
                "value": {
                    "outlook": {
                        "connectionId": "/subscriptions/xxxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/rg/providers/Microsoft.Web/connections/outlook",
                        "connectionName": "outlook",
                        "id": "/subscriptions/xxxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/providers/Microsoft.Web/locations/southindia/managedApis/outlook"
                    },
                    "sharepointonline": {
                        "connectionId": "/subscriptions/xxxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/rg/providers/Microsoft.Web/connections/sharepointonline",
                        "connectionName": "sharepointonline",
                        "id": "/subscriptions/xxxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/providers/Microsoft.Web/locations/southindia/managedApis/sharepointonline"
                    }
                }
            }
        }
    }
    
    
    0 comments No comments