Search code examples
azureazure-storageazure-blob-storageazure-logic-apps

Save the Response from HTTP to Blob Storage using Azure Logic App


Is it possible to save the response from the HTTP request(First Step) into the Blob Storage(Second Step) while using Azure Logic App.

Thank you.


Solution

  • Yes, You can achieve it by using Http and Create blob task. enter image description here

    Code

    {
        "$connections": {
            "value": {
                "azureblob": {
                    "connectionId": "/subscriptions/xxx/resourceGroups/xxx/providers/Microsoft.Web/connections/azureblob",
                    "connectionName": "azureblob",
                    "id": "/subscriptions/xxx/providers/Microsoft.Web/locations/xxx/managedApis/azureblob"
                }
            }
        },
        "definition": {
            "$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
            "actions": {
                "Create_blob": {
                    "inputs": {
                        "body": "@triggerBody()",
                        "host": {
                            "connection": {
                                "name": "@parameters('$connections')['azureblob']['connectionId']"
                            }
                        },
                        "method": "post",
                        "path": "/datasets/default/files",
                        "queries": {
                            "folderPath": "/testing",
                            "name": "Test",
                            "queryParametersSingleEncoded": true
                        }
                    },
                    "runAfter": {},
                    "runtimeConfiguration": {
                        "contentTransfer": {
                            "transferMode": "Chunked"
                        }
                    },
                    "type": "ApiConnection"
                }
            },
            "contentVersion": "1.0.0.0",
            "outputs": {},
            "parameters": {
                "$connections": {
                    "defaultValue": {},
                    "type": "Object"
                }
            },
            "triggers": {
                "HTTP": {
                    "inputs": {
                        "method": "GET",
                        "uri": "https://reqres.in/api/users?page=2"
                    },
                    "recurrence": {
                        "frequency": "Minute",
                        "interval": 3
                    },
                    "type": "Http"
                }
            }
        }
    }
    

    Update 1:

    Just update your blob name with the expression like utcNow('yyyyMMdd')

    enter image description here