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

2

5

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.

Swanskin answered 7/8, 2018 at 12:8 Comment(0)
E
6

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

Electrobiology answered 7/8, 2018 at 15:25 Comment(5)
is it possible to specify the name of the blob as the today's date?Swanskin
@prateek yes it's possible. See my update1 answerElectrobiology
That is great!. I was looking to customize the HTTP url as well.. There are certain params like some token.. that needs to be passed in url dynamically.. Is that possible to configure that well ?Swanskin
@prateek Could you post your query clearly with some example as a new question, because it may help others as well.Electrobiology
For Create blob (v2) this is not so straightforward; body of HTTP response is not available for Blob content. Does anyone have a 2023 response for this?Feminize
B
0

Presuming you have no extraordinary circumstances, yes, you for sure can save the Request content to a Blob. Any Content really.

You will start with the Create Blob Action specifying the Trigger Body as the content.

Don't over think it, it's the same pattern as saving to a local file.

Bulldozer answered 7/8, 2018 at 12:16 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.