Azure logic apps SFTP Copy File action breaks with some SAS Urls

一曲冷凌霜 提交于 2019-12-22 00:14:30

问题


I was experiencing a problem with a logic app which

  1. Used the Create SAS URI by path action to get a SAS-enabled URL for a blob in a storage account

  2. Used the SFTP copy file action to copy the file to an SFTP connector

The process would fail roughly 50% of the time with an authorization error when trying to fetch the blob from storage.

"actions": {
    "Create_SAS_URI_by_path": {
        "inputs": {
            "body": {
                "Permissions": "Read"
            },
            "host": {
                "connection": {
                    "name": "@parameters('$connections')['azureblob']['connectionId']"
                }
            },
            "method": "post",
            "path": "/datasets/default/CreateSharedLinkByPath",
            "queries": {
                "path": "/container-name/SomeSourceFile.csv"
            }
        },
        "runAfter": {},
        "type": "ApiConnection"
    },    
    "Copy_file": {
        "inputs": {
            "host": {
                "connection": {
                    "name": "@parameters('$connections')['sftp']['connectionId']"
                }
            },
            "method": "post",
            "path": "/datasets/default/copyFile",
            "queries": {
                "destination": "testing-if-works.csv",
                "overwrite": true,
                "source": "@{body('Create_SAS_URI_by_path')?['WebUrl']}"
            }
        },
        "runAfter": {
            "Create_SAS_URI_by_path": [
                "Succeeded"
            ]
        },
        "type": "ApiConnection"
    }
}

回答1:


This bug has been fixed in SFTP connector. To make it work, please create a new logic app with appropriate actions.




回答2:


The SFTP connector has a bug which causes it to fail if a SAS Url has a plus sign (%2B) in the signature, presumably due to how the connector code handles the URL when it tries to GET the blob by Url. The fix is to double-encode the plus sign:

"source": "@{replace(body('Create_SAS_URI_by_path')?['WebUrl'], '%2B', '%252B')}"

I'd report this to Microsoft, but can't find the Github repo for the connector. Hope this helps someone else in the future.



来源:https://stackoverflow.com/questions/48212364/azure-logic-apps-sftp-copy-file-action-breaks-with-some-sas-urls

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!