PowerAutomate: Teams の添付ファイルをSharePoint に保存し Lists にまとめたい

# 背景
会社で件名のような要望があったので、Sample 作成してみた

# 概要
1. Teams の Automated Trigger で新しいメッセージを取得
1. Contents を取得して
1. Share に保存
1. Link を取得（合成してもいいけど、面倒なので）
1. Lists に登録

特に躓く事もなくおしまい


# フロー全図
![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/120072/27168626-d702-fb59-5f20-d1acc5989834.png)

# トリガー
![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/120072/e51c3578-2ddc-945f-a6b5-c077b34a50c9.png)

# 保存ファイル
![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/120072/870620d9-ccc4-594b-fe33-b2c976f48f78.png)


# 保存先 Lists
![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/120072/3c2c943d-7533-cf7c-fd66-6bcdaae0971a.png)


# フロー（スコープ内）
```json:スコープ内のみ
{"id":"5798dc33-e3f3-48dc-abd0-014828892087","brandColor":"#8C3900","connectionReferences":{"shared_sharepointonline":{"connection":{"id":"/providers/Microsoft.PowerApps/apis/shared_sharepointonline/connections/shared-sharepointonl-1c8b887c-61a2-4d83-ae95-966e8760de31"}},"shared_teams":{"connection":{"id":"/providers/Microsoft.PowerApps/apis/shared_teams/connections/shared-teams-864099d5-54a7-4002-93b6-565ecf481128"}}},"connectorDisplayName":"Control","icon":"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMzIiIGhlaWdodD0iMzIiIHZlcnNpb249IjEuMSIgdmlld0JveD0iMCAwIDMyIDMyIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPg0KIDxwYXRoIGQ9Im0wIDBoMzJ2MzJoLTMyeiIgZmlsbD0iIzhDMzkwMCIvPg0KIDxwYXRoIGQ9Im04IDEwaDE2djEyaC0xNnptMTUgMTF2LTEwaC0xNHYxMHptLTItOHY2aC0xMHYtNnptLTEgNXYtNGgtOHY0eiIgZmlsbD0iI2ZmZiIvPg0KPC9zdmc+DQo=","isTrigger":false,"operationName":"Scope","operationDefinition":{"type":"Scope","actions":{"Parse_JSON":{"type":"ParseJson","inputs":{"content":"@triggerOutputs()?['body']","schema":{"type":"object","properties":{"@@odata.type":{"type":"string"},"etag":{"type":"string"},"messageType":{"type":"string"},"createdDateTime":{"type":"string"},"lastModifiedDateTime":{"type":"string"},"subject":{"type":"string"},"importance":{"type":"string"},"locale":{"type":"string"},"webUrl":{"type":"string"},"id":{"type":"string"},"from":{"type":"object","properties":{"user":{"type":"object","properties":{"id":{"type":"string"},"displayName":{"type":"string"},"userIdentityType":{"type":"string"}}}}},"body":{"type":"object","properties":{"contentType":{"type":"string"},"content":{"type":"string"}}},"channelIdentity":{"type":"object","properties":{"teamId":{"type":"string"},"channelId":{"type":"string"}}},"attachments":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"contentType":{"type":"string"},"contentUrl":{"type":"string"},"name":{"type":"string"}},"required":["id","contentType","contentUrl","name"]}},"mentions":{"type":"array"},"reactions":{"type":"array"}}}},"runAfter":{}},"Apply_to_each":{"type":"Foreach","foreach":"@body('Parse_JSON')?['attachments']","actions":{"Get_file_content_using_path":{"type":"OpenApiConnection","inputs":{"host":{"connectionName":"shared_sharepointonline","operationId":"GetFileContentByPath","apiId":"/providers/Microsoft.PowerApps/apis/shared_sharepointonline"},"parameters":{"dataset":"https://shimakuma.sharepoint.com/sites/TestForTeams","path":"@items('Apply_to_each')?['contentUrl']","inferContentType":true},"authentication":"@parameters('$authentication')"},"runAfter":{}},"Create_file":{"type":"OpenApiConnection","inputs":{"host":{"connectionName":"shared_sharepointonline","operationId":"CreateFile","apiId":"/providers/Microsoft.PowerApps/apis/shared_sharepointonline"},"parameters":{"dataset":"https://shimakuma.sharepoint.com/sites/testforflow","folderPath":"/Shared Documents/StoreOfTeamsAttachments","name":"@items('Apply_to_each')?['name']","body":"@body('Get_file_content_using_path')"},"authentication":"@parameters('$authentication')"},"runAfter":{"Get_file_content_using_path":["Succeeded"]},"runtimeConfiguration":{"contentTransfer":{"transferMode":"Chunked"}}},"Create_item":{"type":"OpenApiConnection","inputs":{"host":{"connectionName":"shared_sharepointonline","operationId":"PostItem","apiId":"/providers/Microsoft.PowerApps/apis/shared_sharepointonline"},"parameters":{"dataset":"https://shimakuma.sharepoint.com/sites/testforflow","table":"b79efdac-dc1b-46c0-a97d-7f1d2f1e08cc","item/Title":"@outputs('Get_file_properties')?['body/{Name}']","item/URL":"@outputs('Get_file_properties')?['body/{Link}']"},"authentication":"@parameters('$authentication')"},"runAfter":{"Get_file_properties":["Succeeded"]}},"Get_file_properties":{"type":"OpenApiConnection","inputs":{"host":{"connectionName":"shared_sharepointonline","operationId":"GetFileItem","apiId":"/providers/Microsoft.PowerApps/apis/shared_sharepointonline"},"parameters":{"dataset":"https://shimakuma.sharepoint.com/sites/testforflow","table":"77cbc9b8-4538-4e2b-b0d7-4eee344e8317","id":"@outputs('Create_file')?['body/ItemId']"},"authentication":"@parameters('$authentication')"},"runAfter":{"Create_file":["Succeeded"]}}},"runAfter":{"Parse_JSON":["Succeeded"]}}},"runAfter":{}}}
```

# あとがき
Sample 作るほどでもなかったような気がする・・