迁移多个文件从一个 Azure 存储容器到另一个容器,使用 Azure Logic Apps。

huangapple go评论59阅读模式
英文:

migrate multiple files from one storage container to another container using azure logicapps

问题

我已经创建了逻辑应用,如图所示。我的要求是将输入容器中的所有文件/数据移动到同一存储和不同存储账户中的输出容器。

在存储账户容器图像中显示,我有多个文件,但是按照上述工作流程,我一次只能发送一个文件。
请详细告诉我如何一次发送多个文件的工作流程,以及如何在同一存储账户和不同存储账户中发送它们。

我遇到的错误

我创建的工作流程

输入容器中的3个不同文件

执行上述工作流程后,如图所示,我能够获得输出容器中的内容

注意:我已按照提供的解决方案创建了工作流程,但正如您所看到的,我的要求是我希望输入容器中的所有文件都以相同的名称出现在输出容器中。

英文:

迁移多个文件从一个 Azure 存储容器到另一个容器,使用 Azure Logic Apps。

I have created logic app as shown in image. My requirement is moving all files/data in my input container to output container with in same storage and diff storage account.

迁移多个文件从一个 Azure 存储容器到另一个容器,使用 Azure Logic Apps。

As shown in storage account container image i have multiple files but i am able to send onle one file at a time by following above mentioned workflow.
please let me know the workflow in detail how can i send multiple files at a time with in same storage account and also different storage account.
error i am getting

workflow i created

3 different files in input container

After performing above workflow as said i able to get as shown in output container

Note: i have created workflow as provided in solution but as you can see my requirement is i want all files in input as it is in output container means i want those 3 input container files in output container with those names.

答案1

得分: 0

我在我的环境中进行了复制,并得到了如下的期望结果:

我的存储账户包含2个文件,以下设计获取了2个文件的数据:

逻辑应用设计:

迁移多个文件从一个 Azure 存储容器到另一个容器,使用 Azure Logic Apps。

在"Get Blob"中添加 /conatinername/items('For_Each')['Name']

迁移多个文件从一个 Azure 存储容器到另一个容器,使用 Azure Logic Apps。

输出:

迁移多个文件从一个 Azure 存储容器到另一个容器,使用 Azure Logic Apps。

第二个文件:

迁移多个文件从一个 Azure 存储容器到另一个容器,使用 Azure Logic Apps。

代码视图:

{
    "definition": {
        "$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
        "actions": {
            "For_each": {
                "actions": {
                    "Get_blob_content_(V2)": {
                        "inputs": {
                            "host": {
                                "connection": {
                                    "name": "@parameters('$connections')['azureblob']['connectionId']"
                                }
                            },
                            "method": "get",
                            "path": "/v2/datasets/@{encodeURIComponent(encodeURIComponent('AccountNameFromSettings'))}/files/@{encodeURIComponent(encodeURIComponent('/rithwik/',items('For_Each')['Name']))}/content",
                            "queries": {
                                "inferContentType": true
                            }
                        },
                        "runAfter": {},
                        "type": "ApiConnection"
                    }
                },
                "foreach": "@body('Lists_blobs_(V2)')?['value']",
                "runAfter": {
                    "Lists_blobs_(V2)": [
                        "Succeeded"
                    ]
                },
                "type": "Foreach"
            },
            "Lists_blobs_(V2)": {
                "inputs": {
                    "host": {
                        "connection": {
                            "name": "@parameters('$connections')['azureblob']['connectionId']"
                        }
                    },
                    "method": "get",
                    "path": "/v2/datasets/@{encodeURIComponent(encodeURIComponent('AccountNameFromSettings'))}/foldersV2/@{encodeURIComponent(encodeURIComponent('JTJmcml0aHdpaw=='))}",
                    "queries": {
                        "nextPageMarker": "",
                        "useFlatListing": false
                    }
                },
                "metadata": {
                    "JTJmcml0aHdpaw==": "/rithwik"
                },
                "runAfter": {},
                "type": "ApiConnection"
            }
        },
        "contentVersion": "1.0.0.0",
        "outputs": {},
        "parameters": {
            "$connections": {
                "defaultValue": {},
                "type": "Object"
            }
        },
        "triggers": {
            "manual": {
                "inputs": {
                    "schema": {}
                },
                "kind": "Http",
                "type": "Request"
            }
        }
    },
    "parameters": {
        "$connections": {
            "value": {
                "azureblob": {
                    "connectionId": "/subscriptions/b83c/resourceGroups/rbojjae/providers/Microsoft.Web/connections/azureblob",
                    "connectionName": "azureblob",
                    "id": "/subscriptions/b83cf/providers/Microsoft.Web/locations/eastus/managedApis/azureblob"
                }
            }
        }
    }
}

通过这种方式,您可以循环遍历文件列表。

编辑:

要将文件复制到不同的存储账户,请使用"Copy Blob",然后更改连接:

迁移多个文件从一个 Azure 存储容器到另一个容器,使用 Azure Logic Apps。

迁移多个文件从一个 Azure 存储容器到另一个容器,使用 Azure Logic Apps。

编辑-2

输出:

迁移多个文件从一个 Azure 存储容器到另一个容器,使用 Azure Logic Apps。

设计:

迁移多个文件从一个 Azure 存储容器到另一个容器,使用 Azure Logic Apps。

"st2"是第二个存储账户中的容器。

英文:

I have reproduced in my environment and got expected results as below:

My Storage account contains 2 files and below design gets the data of 2 files:

迁移多个文件从一个 Azure 存储容器到另一个容器,使用 Azure Logic Apps。

Logic App Design:

迁移多个文件从一个 Azure 存储容器到另一个容器,使用 Azure Logic Apps。

In get blob add /conatinername/items('For_Each')['Name']

迁移多个文件从一个 Azure 存储容器到另一个容器,使用 Azure Logic Apps。

Output:

迁移多个文件从一个 Azure 存储容器到另一个容器,使用 Azure Logic Apps。

2nd file :

迁移多个文件从一个 Azure 存储容器到另一个容器,使用 Azure Logic Apps。

Code view:

{
    "definition": {
        "$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
        "actions": {
            "For_each": {
                "actions": {
                    "Get_blob_content_(V2)": {
                        "inputs": {
                            "host": {
                                "connection": {
                                    "name": "@parameters('$connections')['azureblob']['connectionId']"
                                }
                            },
                            "method": "get",
                            "path": "/v2/datasets/@{encodeURIComponent(encodeURIComponent('AccountNameFromSettings'))}/files/@{encodeURIComponent(encodeURIComponent('/rithwik/',items('For_Each')['Name']))}/content",
                            "queries": {
                                "inferContentType": true
                            }
                        },
                        "runAfter": {},
                        "type": "ApiConnection"
                    }
                },
                "foreach": "@body('Lists_blobs_(V2)')?['value']",
                "runAfter": {
                    "Lists_blobs_(V2)": [
                        "Succeeded"
                    ]
                },
                "type": "Foreach"
            },
            "Lists_blobs_(V2)": {
                "inputs": {
                    "host": {
                        "connection": {
                            "name": "@parameters('$connections')['azureblob']['connectionId']"
                        }
                    },
                    "method": "get",
                    "path": "/v2/datasets/@{encodeURIComponent(encodeURIComponent('AccountNameFromSettings'))}/foldersV2/@{encodeURIComponent(encodeURIComponent('JTJmcml0aHdpaw=='))}",
                    "queries": {
                        "nextPageMarker": "",
                        "useFlatListing": false
                    }
                },
                "metadata": {
                    "JTJmcml0aHdpaw==": "/rithwik"
                },
                "runAfter": {},
                "type": "ApiConnection"
            }
        },
        "contentVersion": "1.0.0.0",
        "outputs": {},
        "parameters": {
            "$connections": {
                "defaultValue": {},
                "type": "Object"
            }
        },
        "triggers": {
            "manual": {
                "inputs": {
                    "schema": {}
                },
                "kind": "Http",
                "type": "Request"
            }
        }
    },
    "parameters": {
        "$connections": {
            "value": {
                "azureblob": {
                    "connectionId": "/subscriptions/b83c/resourceGroups/rbojjae/providers/Microsoft.Web/connections/azureblob",
                    "connectionName": "azureblob",
                    "id": "/subscriptions/b83cf/providers/Microsoft.Web/locations/eastus/managedApis/azureblob"
                }
            }
        }
    }
}

By this way you can loop the list of files.

EDIT:

To copy file to different storage account use Copy blob and now change the connection:
迁移多个文件从一个 Azure 存储容器到另一个容器,使用 Azure Logic Apps。

迁移多个文件从一个 Azure 存储容器到另一个容器,使用 Azure Logic Apps。

Edit-2

Output:

迁移多个文件从一个 Azure 存储容器到另一个容器,使用 Azure Logic Apps。

Design:

迁移多个文件从一个 Azure 存储容器到另一个容器,使用 Azure Logic Apps。

st2 is conatiner in 2nd storage account.

huangapple
  • 本文由 发表于 2023年6月26日 17:51:41
  • 转载请务必保留本文链接:https://go.coder-hub.com/76555531.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定