简体   繁体   English

如何将成员从安全组获取到 Sharepoint 上的文件 - 逻辑应用

[英]How to get members from Security Group to a File on Sharepoint - Logic App

I am creating a logic app that would get members from security groups and then writes that to a CSV file, or any file located on a sharepoint folder.我正在创建一个逻辑应用程序,它将从安全组中获取成员,然后将其写入 CSV 文件或位于 sharepoint 文件夹中的任何文件。

I have gotten so far that I can get the members of multiple groups in a for each loop.到目前为止,我可以在 for each 循环中获取多个组的成员。 I am stuck at getting this in 1 single CSV.我坚持在 1 个 CSV 中得到这个。

The result should be the Name of the Group in column 1 and the email of the member in column2.结果应为第 1 列中的组名称和第 2 列中成员的 email。 I've tried many multiple things already, but cant seem to figure it out.我已经尝试了很多事情,但似乎无法弄清楚。

This is my current set-up that returns bad parsed results for just 1 group.这是我当前的设置,它只为一组返回错误的解析结果。

在此处输入图像描述

How should I handle this?我该如何处理?

See below a sample of the result of 1 Group:请参阅下面的 1 组结果示例:

{
"statusCode": 200,
"headers": {
    "Transfer-Encoding": "chunked",
    "Vary": "Accept-Encoding",
    "Strict-Transport-Security": "max-age=31536000",
    "request-id": "76grrfc-3313-4103-8275-026e4e23777e",
    "client-request-id": "76fb31fc-3313rrrr5-026e4e23777e",
    "x-ms-ags-diagnostic": "{\"ServerInfo\":{\"DataCenter\":\"West Europe\",\"Slice\":\"E\",\"Ring\":\"5\",\"ScaleUnit\":\"000\",\"RoleInstance\":\"AM1PE00105B7\"}}",
    "x-ms-resource-unit": "3",
    "OData-Version": "4.0",
    "Cache-Control": "no-cache",
    "Date": "Tue, 29 Mar 2022 15:07:18 GMT",
    "Content-Type": "application/json; odata.metadata=minimal; odata.streaming=true; IEEE754Compatible=false; charset=utf-8",
    "Content-Length": "1724"
},
"body": {
    "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#directoryObjects",
    "value": [
        {
            "@odata.type": "#microsoft.graph.user",
            "id": "de2ae485-a578-439a-9bd2-991445a",
            "businessPhones": [
                "+12222"
            ],
            "displayName": "Jaaa",
            "givenName": "a",
            "jobTitle": "aaa",
            "mail": "aaaa",
            "mobilePhone": "+0000",
            "officeLocation": "aaa",
            "preferredLanguage": null,
            "surname": "aaa",
            "userPrincipalName": "aaa"
        },
        {
            "@odata.type": "#microsoft.graph.user",
            "id": "de2ae485-a578-439a-9bd2-991445a",
            "businessPhones": [
                "+12222"
            ],
            "displayName": "Jaaa",
            "givenName": "a",
            "jobTitle": "aaa",
            "mail": "aaaa",
            "mobilePhone": "+0000",
            "officeLocation": "aaa",
            "preferredLanguage": null,
            "surname": "aaa",
            "userPrincipalName": "aaa"
        },
        {
            "@odata.type": "#microsoft.graph.user",
            "id": "de2ae485-a578-439a-9bd2-991445a",
            "businessPhones": [
                "+12222"
            ],
            "displayName": "Jaaa",
            "givenName": "a",
            "jobTitle": "aaa",
            "mail": "aaaa",
            "mobilePhone": "+0000",
            "officeLocation": "aaa",
            "preferredLanguage": null,
            "surname": "aaa",
            "userPrincipalName": "aaa"
        },
        {
            "@odata.type": "#microsoft.graph.user",
            "id": "de2ae485-a578-439a-9bd2-991445a",
            "businessPhones": [
                "+12222"
            ],
            "displayName": "Jaaa",
            "givenName": "a",
            "jobTitle": "aaa",
            "mail": "aaaa",
            "mobilePhone": "+0000",
            "officeLocation": "aaa",
            "preferredLanguage": null,
            "surname": "aaa",
            "userPrincipalName": "aaa"
        }
    ]
}

} }

Error on CSV Table: CSV 表出错: 在此处输入图像描述

I've taken your array and created a flow using an approach I would use.我已经使用你的数组并使用我将使用的方法创建了一个流程。

Note: The @odata syntax fails to parse so I had to remove the @ sign when testing.注意: @odata语法无法解析,因此我不得不在测试时删除@符号。 See how that affects you with your real life scenario.了解这对您的现实生活场景有何影响。

The high level steps are:高级步骤是:

  1. Create two arrays, one with the source data and the other with the CSV/destination data.创建两个 arrays,一个包含源数据,另一个包含 CSV/目标数据。
  2. Loop through each element in your source array and Compose an object that contains only the two fields you want to include in your CSV data.遍历源数组中的每个元素并Compose一个 object,它仅包含您想要包含在 CSV 数据中的两个字段。
  3. Append that new object to the CSV/destination array. Append 新的 object 到 CSV/目标数组。
  4. After the loop is done, write out the CSV/destination array to a CSV structure using the Create CSV table action.循环完成后,使用Create CSV table操作将 CSV/目标数组写入 CSV 结构。

This is the end result...这是最终的结果...

结果

If you want to make sure the array is in the desired order, make sure you change the settings on the For each and turn concurrency off...如果要确保数组按所需顺序排列,请确保更改For each上的设置并关闭并发...

并发

This is the JSON definition that you can load into your own tenant for testing...这是 JSON 定义,您可以加载到您自己的租户中进行测试...

{
    "definition": {
        "$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
        "actions": {
            "Create_CSV_table": {
                "inputs": {
                    "format": "CSV",
                    "from": "@variables('CSV Array')"
                },
                "runAfter": {
                    "For_each": [
                        "Succeeded"
                    ]
                },
                "type": "Table"
            },
            "For_each": {
                "actions": {
                    "Append_to_array_variable": {
                        "inputs": {
                            "name": "CSV Array",
                            "value": "@outputs('Compose')"
                        },
                        "runAfter": {
                            "Compose": [
                                "Succeeded"
                            ]
                        },
                        "type": "AppendToArrayVariable"
                    },
                    "Compose": {
                        "inputs": {
                            "displayName": "@{items('For_each')['displayName']}",
                            "mail": "@{items('For_each')['mail']}"
                        },
                        "runAfter": {},
                        "type": "Compose"
                    }
                },
                "foreach": "@variables('JSON Array')",
                "runAfter": {
                    "Initialize_CSV_Array": [
                        "Succeeded"
                    ]
                },
                "type": "Foreach"
            },
            "Initialize_CSV_Array": {
                "inputs": {
                    "variables": [
                        {
                            "name": "CSV Array",
                            "type": "array"
                        }
                    ]
                },
                "runAfter": {
                    "Initialize_Source_Array": [
                        "Succeeded"
                    ]
                },
                "type": "InitializeVariable"
            },
            "Initialize_Source_Array": {
                "inputs": {
                    "variables": [
                        {
                            "name": "JSON Array",
                            "type": "array",
                            "value": [
                                {
                                    "businessPhones": [
                                        "+12222"
                                    ],
                                    "displayName": "Jaaa 1",
                                    "givenName": "a",
                                    "id": "de2ae485-a578-439a-9bd2-991445a",
                                    "jobTitle": "aaa",
                                    "mail": "aaaa 1",
                                    "mobilePhone": "+0000",
                                    "odata.type": "#microsoft.graph.user",
                                    "officeLocation": "aaa",
                                    "preferredLanguage": null,
                                    "surname": "aaa",
                                    "userPrincipalName": "aaa"
                                },
                                {
                                    "businessPhones": [
                                        "+12222"
                                    ],
                                    "displayName": "Jaaa 2",
                                    "givenName": "a",
                                    "id": "de2ae485-a578-439a-9bd2-991445a",
                                    "jobTitle": "aaa",
                                    "mail": "aaaa 2",
                                    "mobilePhone": "+0000",
                                    "odata.type": "#microsoft.graph.user",
                                    "officeLocation": "aaa",
                                    "preferredLanguage": null,
                                    "surname": "aaa",
                                    "userPrincipalName": "aaa"
                                },
                                {
                                    "businessPhones": [
                                        "+12222"
                                    ],
                                    "displayName": "Jaaa 3",
                                    "givenName": "a",
                                    "id": "de2ae485-a578-439a-9bd2-991445a",
                                    "jobTitle": "aaa",
                                    "mail": "aaaa 3",
                                    "mobilePhone": "+0000",
                                    "odata.type": "#microsoft.graph.user",
                                    "officeLocation": "aaa",
                                    "preferredLanguage": null,
                                    "surname": "aaa",
                                    "userPrincipalName": "aaa"
                                },
                                {
                                    "businessPhones": [
                                        "+12222"
                                    ],
                                    "displayName": "Jaaa 4",
                                    "givenName": "a",
                                    "id": "de2ae485-a578-439a-9bd2-991445a",
                                    "jobTitle": "aaa",
                                    "mail": "aaaa 4",
                                    "mobilePhone": "+0000",
                                    "odata.type": "#microsoft.graph.user",
                                    "officeLocation": "aaa",
                                    "preferredLanguage": null,
                                    "surname": "aaa",
                                    "userPrincipalName": "aaa"
                                }
                            ]
                        }
                    ]
                },
                "runAfter": {},
                "type": "InitializeVariable"
            }
        },
        "contentVersion": "1.0.0.0",
        "outputs": {},
        "parameters": {},
        "triggers": {
            "Recurrence": {
                "evaluatedRecurrence": {
                    "frequency": "Month",
                    "interval": 12
                },
                "recurrence": {
                    "frequency": "Month",
                    "interval": 12
                },
                "type": "Recurrence"
            }
        }
    },
    "parameters": {}
}

In the Create CSV table option, you should be able to specify custom headers and then be specific about what you pull back from each item in your array.Create CSV table选项中,您应该能够指定自定义标头,然后具体说明您从数组中的每个项目中提取的内容。

I took your JSON and created my own flow to show just that.我拿了你的 JSON 并创建了我自己的流程来展示这一点。

Note: The @odata syntax fails to parse so I had to remove the @ sign when testing.注意: @odata 语法无法解析,因此我不得不在测试时删除 @ 符号。 See how that affects you with your real life scenario.了解这对您的现实生活场景有何影响。

创建 CSV 表

The two expressions are in the definition below but for completeness, they are...这两个表达式在下面的定义中,但为了完整起见,它们是......

displayName = item()['displayName'] displayName = item()['displayName']

mail = item()['mail']邮件= item()['mail']

This is the result...这是结果...

结果

This is the JSON definition that you can load into your own tenant for testing...这是 JSON 定义,您可以加载到您自己的租户中进行测试...

{
    "definition": {
        "$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
        "actions": {
            "Create_CSV_table": {
                "inputs": {
                    "columns": [
                        {
                            "header": "displayName",
                            "value": "@item()['displayName']"
                        },
                        {
                            "header": "mail",
                            "value": "@item()['mail']"
                        }
                    ],
                    "format": "CSV",
                    "from": "@variables('JSON Array')"
                },
                "runAfter": {
                    "Initialize_Source_Array": [
                        "Succeeded"
                    ]
                },
                "type": "Table"
            },
            "Initialize_Source_Array": {
                "inputs": {
                    "variables": [
                        {
                            "name": "JSON Array",
                            "type": "array",
                            "value": [
                                {
                                    "businessPhones": [
                                        "+12222"
                                    ],
                                    "displayName": "Jaaa 1",
                                    "givenName": "a",
                                    "id": "de2ae485-a578-439a-9bd2-991445a",
                                    "jobTitle": "aaa",
                                    "mail": "aaaa 1",
                                    "mobilePhone": "+0000",
                                    "odata.type": "#microsoft.graph.user",
                                    "officeLocation": "aaa",
                                    "preferredLanguage": null,
                                    "surname": "aaa",
                                    "userPrincipalName": "aaa"
                                },
                                {
                                    "businessPhones": [
                                        "+12222"
                                    ],
                                    "displayName": "Jaaa 2",
                                    "givenName": "a",
                                    "id": "de2ae485-a578-439a-9bd2-991445a",
                                    "jobTitle": "aaa",
                                    "mail": "aaaa 2",
                                    "mobilePhone": "+0000",
                                    "odata.type": "#microsoft.graph.user",
                                    "officeLocation": "aaa",
                                    "preferredLanguage": null,
                                    "surname": "aaa",
                                    "userPrincipalName": "aaa"
                                },
                                {
                                    "businessPhones": [
                                        "+12222"
                                    ],
                                    "displayName": "Jaaa 3",
                                    "givenName": "a",
                                    "id": "de2ae485-a578-439a-9bd2-991445a",
                                    "jobTitle": "aaa",
                                    "mail": "aaaa 3",
                                    "mobilePhone": "+0000",
                                    "odata.type": "#microsoft.graph.user",
                                    "officeLocation": "aaa",
                                    "preferredLanguage": null,
                                    "surname": "aaa",
                                    "userPrincipalName": "aaa"
                                },
                                {
                                    "businessPhones": [
                                        "+12222"
                                    ],
                                    "displayName": "Jaaa 4",
                                    "givenName": "a",
                                    "id": "de2ae485-a578-439a-9bd2-991445a",
                                    "jobTitle": "aaa",
                                    "mail": "aaaa 4",
                                    "mobilePhone": "+0000",
                                    "odata.type": "#microsoft.graph.user",
                                    "officeLocation": "aaa",
                                    "preferredLanguage": null,
                                    "surname": "aaa",
                                    "userPrincipalName": "aaa"
                                }
                            ]
                        }
                    ]
                },
                "runAfter": {},
                "type": "InitializeVariable"
            }
        },
        "contentVersion": "1.0.0.0",
        "outputs": {},
        "parameters": {},
        "triggers": {
            "Recurrence": {
                "evaluatedRecurrence": {
                    "frequency": "Month",
                    "interval": 12
                },
                "recurrence": {
                    "frequency": "Month",
                    "interval": 12
                },
                "type": "Recurrence"
            }
        }
    },
    "parameters": {}
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用逻辑应用程序将最新文件从 Sharepoint 复制到 Blob 存储? - How to copy the latest file from Sharepoint to Blob Storage using Logic App? Logic App Sharepoint 拉取文件时文件名错误 - Logic App Sharepoint File Name Wrong When Pulling File 从逻辑应用触发 Azure 操作组 - Trigger Azure Action Group from a Logic App 如何在Azure中设置逻辑应用,根据名称将文件从blob存储传输到sharepoint? - How do I set a logic app in Azure to transfer files from blob storage to sharepoint based on the name? 从逻辑应用中的响应中获取 cookie 数据 - Get cookie data from response in Logic App azure devops project项目管理员群如何获取成员 - How to get members of a azure devops project project administrator group 如何获取应用程序安全组/资源组的 NIC 详细信息 - How to get the NIC details for Application Security Group / Resource Group 在 Azure 中的逻辑应用程序上获取文件内容活动 - Get file content acitivity on a Logic App in Azure 通过 web 活动从 azure 广告获取群组成员 - get group members from azure ad via web activity 在 Sharepoint 的父文件夹中循环时,逻辑应用返回获取文件内容的错误 404 - Logic Apps returns Error 404 for Get File Content while Looping in Sharepoint's parent folder
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM