带有Azure Logic应用的Azure存储容器的清单和查看内容?

发布于 2025-02-02 06:30:14 字数 106 浏览 1 评论 0原文

在Azure中,将为Azure存储中的每个用户制作一个容器,我希望能够列出容器并查看内容的大小,以确保其不超过一定限制。是否可以使用Azure Logic应用程序执行此操作?我没有找到这样做的功能。

In Azure a container will be made for each user in Azure Storage, I want to be able to list the container and view the size of the content to ensure it does not exceed a certain limit. Is it possible to do this with Azure Logic Apps? I am not finding functions to do so.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

維他命╮ 2025-02-09 06:30:14

是的,这是通过逻辑应用程序可以的。您可以使用“ get blob metadata(v2)”获取文件的所有属性,如果您试图获取内容,则可以使用“ get blob content(v2)”。为了重现此功能,我首先创建了3个容器(IE,Container1,Container2和Container3),然后将一些文件上传到这些尺寸不同的容器中。要获取所有使用列表的所有容器的列表,请列表blobs(v2)和used 列表blobs(v2)从上一个步骤到迭代的路径容器内的斑点。

在下一步中,我正在使用get blob metadata(v2)使用list blobs path获取每个斑点的属性。

然后使用条件操作我正在提取小于9128字节的斑点,并将所有这些数据存储到变量中。

最后,我正在使用Complose Connector以及大小和路径一起查看所有文件。

结果:

”在此处输入图像描述”

“

”

您可以尝试使用以下代码视图来尝试使用以下代码视图在您的环境中测试

{
    "definition": {
        "$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
        "actions": {
            "Compose": {
                "inputs": "@variables('FilesWithinLimit')",
                "runAfter": {
                    "For_each": [
                        "Succeeded"
                    ]
                },
                "type": "Compose"
            },
            "Compose_2": {
                "inputs": "@variables('FilesOutOfLimit')",
                "runAfter": {
                    "For_each": [
                        "Succeeded"
                    ]
                },
                "type": "Compose"
            },
            "FilesOutOfLimit": {
                "inputs": {
                    "variables": [
                        {
                            "name": "FilesOutOfLimit",
                            "type": "array"
                        }
                    ]
                },
                "runAfter": {
                    "FilesWithinLimit": [
                        "Succeeded"
                    ]
                },
                "type": "InitializeVariable"
            },
            "FilesWithinLimit": {
                "inputs": {
                    "variables": [
                        {
                            "name": "FilesWithinLimit",
                            "type": "array"
                        }
                    ]
                },
                "runAfter": {},
                "type": "InitializeVariable"
            },
            "For_each": {
                "actions": {
                    "For_each_2": {
                        "actions": {
                            "Condition": {
                                "actions": {
                                    "Append_to_FilesWithinLimit": {
                                        "inputs": {
                                            "name": "FilesWithinLimit",
                                            "value": {
                                                "Name": "@{body('Get_Blob_Metadata_(V2)')?['DisplayName']}",
                                                "Path": "@{body('Get_Blob_Metadata_(V2)')?['Path']}",
                                                "Size": "@{body('Get_Blob_Metadata_(V2)')?['Size']}"
                                            }
                                        },
                                        "runAfter": {},
                                        "type": "AppendToArrayVariable"
                                    }
                                },
                                "else": {
                                    "actions": {
                                        "Append_to_FilesOutOfLimit": {
                                            "inputs": {
                                                "name": "FilesOutOfLimit",
                                                "value": {
                                                    "Name": "@{body('Get_Blob_Metadata_(V2)')?['DisplayName']}",
                                                    "Path": "@{body('Get_Blob_Metadata_(V2)')?['Path']}",
                                                    "Size": "@{body('Get_Blob_Metadata_(V2)')?['Size']}"
                                                }
                                            },
                                            "runAfter": {},
                                            "type": "AppendToArrayVariable"
                                        }
                                    }
                                },
                                "expression": {
                                    "and": [
                                        {
                                            "lessOrEquals": [
                                                "@body('Get_Blob_Metadata_(V2)')?['Size']",
                                                9128
                                            ]
                                        }
                                    ]
                                },
                                "runAfter": {
                                    "Get_Blob_Metadata_(V2)": [
                                        "Succeeded"
                                    ]
                                },
                                "type": "If"
                            },
                            "Get_Blob_Metadata_(V2)": {
                                "inputs": {
                                    "host": {
                                        "connection": {
                                            "name": "@parameters('$connections')['azureblob']['connectionId']"
                                        }
                                    },
                                    "method": "get",
                                    "path": "/v2/datasets/@{encodeURIComponent(encodeURIComponent('AccountNameFromSettings'))}/files/@{encodeURIComponent(encodeURIComponent(items('For_each_2')?['Path']))}"
                                },
                                "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(items('For_each')?['Path']))}",
                            "queries": {
                                "nextPageMarker": ""
                            }
                        },
                        "runAfter": {},
                        "type": "ApiConnection"
                    }
                },
                "foreach": "@body('Lists_blobs_in_the_root_folder__(V2)')?['value']",
                "runAfter": {
                    "Lists_blobs_in_the_root_folder__(V2)": [
                        "Succeeded"
                    ]
                },
                "type": "Foreach"
            },
            "Lists_blobs_in_the_root_folder__(V2)": {
                "inputs": {
                    "host": {
                        "connection": {
                            "name": "@parameters('$connections')['azureblob']['connectionId']"
                        }
                    },
                    "method": "get",
                    "path": "/v2/datasets/@{encodeURIComponent(encodeURIComponent('AccountNameFromSettings'))}/foldersV2",
                    "queries": {
                        "nextPageMarker": "",
                        "useFlatListing": false
                    }
                },
                "runAfter": {
                    "FilesOutOfLimit": [
                        "Succeeded"
                    ]
                },
                "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/<Your_SUBSCRIPTION_ID>/resourceGroups/<YOUR_RESOURCE_GROUP>/providers/Microsoft.Web/connections/azureblob",
                    "connectionName": "azureblob",
                    "id": "/subscriptions/<Your_SUBSCRIPTION_ID>/providers/Microsoft.Web/locations/centralus/managedApis/azureblob"
                }
            }
        }
    }
}

yes, this is possible through logic apps. You can use 'Get Blob Metadata (V2)' to get all the properties of the files and if you are trying to get the content, you can use 'Get blob content (V2)'. To reproduce this I first created 3 containers (i.e., Container1, Container2, and Container3) and uploaded a few files into these containers with different sizes. To get the list of all the containers I have used Lists blobs in the root folder (V2) and used Lists blobs (V2) taking the path from the previous step to iterate blobs inside the containers.

enter image description here

In the next step I'm using Get Blob Metadata (V2) to get the properties of each blob using list blobs path.

enter image description here

Then using Condition action I'm extracting the blobs which are less than 9128 bytes and storing all this data into variables.

enter image description here

Finally, I'm using compose connector to view all the files along with size and path.

enter image description here

RESULT:

enter image description here

enter image description here

enter image description here

You can try using the below code view to test in your environment

{
    "definition": {
        "$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
        "actions": {
            "Compose": {
                "inputs": "@variables('FilesWithinLimit')",
                "runAfter": {
                    "For_each": [
                        "Succeeded"
                    ]
                },
                "type": "Compose"
            },
            "Compose_2": {
                "inputs": "@variables('FilesOutOfLimit')",
                "runAfter": {
                    "For_each": [
                        "Succeeded"
                    ]
                },
                "type": "Compose"
            },
            "FilesOutOfLimit": {
                "inputs": {
                    "variables": [
                        {
                            "name": "FilesOutOfLimit",
                            "type": "array"
                        }
                    ]
                },
                "runAfter": {
                    "FilesWithinLimit": [
                        "Succeeded"
                    ]
                },
                "type": "InitializeVariable"
            },
            "FilesWithinLimit": {
                "inputs": {
                    "variables": [
                        {
                            "name": "FilesWithinLimit",
                            "type": "array"
                        }
                    ]
                },
                "runAfter": {},
                "type": "InitializeVariable"
            },
            "For_each": {
                "actions": {
                    "For_each_2": {
                        "actions": {
                            "Condition": {
                                "actions": {
                                    "Append_to_FilesWithinLimit": {
                                        "inputs": {
                                            "name": "FilesWithinLimit",
                                            "value": {
                                                "Name": "@{body('Get_Blob_Metadata_(V2)')?['DisplayName']}",
                                                "Path": "@{body('Get_Blob_Metadata_(V2)')?['Path']}",
                                                "Size": "@{body('Get_Blob_Metadata_(V2)')?['Size']}"
                                            }
                                        },
                                        "runAfter": {},
                                        "type": "AppendToArrayVariable"
                                    }
                                },
                                "else": {
                                    "actions": {
                                        "Append_to_FilesOutOfLimit": {
                                            "inputs": {
                                                "name": "FilesOutOfLimit",
                                                "value": {
                                                    "Name": "@{body('Get_Blob_Metadata_(V2)')?['DisplayName']}",
                                                    "Path": "@{body('Get_Blob_Metadata_(V2)')?['Path']}",
                                                    "Size": "@{body('Get_Blob_Metadata_(V2)')?['Size']}"
                                                }
                                            },
                                            "runAfter": {},
                                            "type": "AppendToArrayVariable"
                                        }
                                    }
                                },
                                "expression": {
                                    "and": [
                                        {
                                            "lessOrEquals": [
                                                "@body('Get_Blob_Metadata_(V2)')?['Size']",
                                                9128
                                            ]
                                        }
                                    ]
                                },
                                "runAfter": {
                                    "Get_Blob_Metadata_(V2)": [
                                        "Succeeded"
                                    ]
                                },
                                "type": "If"
                            },
                            "Get_Blob_Metadata_(V2)": {
                                "inputs": {
                                    "host": {
                                        "connection": {
                                            "name": "@parameters('$connections')['azureblob']['connectionId']"
                                        }
                                    },
                                    "method": "get",
                                    "path": "/v2/datasets/@{encodeURIComponent(encodeURIComponent('AccountNameFromSettings'))}/files/@{encodeURIComponent(encodeURIComponent(items('For_each_2')?['Path']))}"
                                },
                                "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(items('For_each')?['Path']))}",
                            "queries": {
                                "nextPageMarker": ""
                            }
                        },
                        "runAfter": {},
                        "type": "ApiConnection"
                    }
                },
                "foreach": "@body('Lists_blobs_in_the_root_folder__(V2)')?['value']",
                "runAfter": {
                    "Lists_blobs_in_the_root_folder__(V2)": [
                        "Succeeded"
                    ]
                },
                "type": "Foreach"
            },
            "Lists_blobs_in_the_root_folder__(V2)": {
                "inputs": {
                    "host": {
                        "connection": {
                            "name": "@parameters('$connections')['azureblob']['connectionId']"
                        }
                    },
                    "method": "get",
                    "path": "/v2/datasets/@{encodeURIComponent(encodeURIComponent('AccountNameFromSettings'))}/foldersV2",
                    "queries": {
                        "nextPageMarker": "",
                        "useFlatListing": false
                    }
                },
                "runAfter": {
                    "FilesOutOfLimit": [
                        "Succeeded"
                    ]
                },
                "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/<Your_SUBSCRIPTION_ID>/resourceGroups/<YOUR_RESOURCE_GROUP>/providers/Microsoft.Web/connections/azureblob",
                    "connectionName": "azureblob",
                    "id": "/subscriptions/<Your_SUBSCRIPTION_ID>/providers/Microsoft.Web/locations/centralus/managedApis/azureblob"
                }
            }
        }
    }
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文