LoginSignup
2
1

More than 1 year has passed since last update.

Power Automate: 外部サイトのファイル更新の検知をファイルサイズで行う

Posted at

背景

外部サイトにある Excel ファイルの情報を Power BI で見える化する際に、
対象ファイルが更新された時だけに通知が欲しい。

ということで、検知方法を検討してみた記録

概要

  • One Drive に アップロード
  • 最新と以前のファイルサイズを比較
  • 差分があった場合
    • 通知
    • 以前のファイルを最新ファイルで上書き

注意

  • Share / One Drive での保存ファイルサイズは相違があるので、比較する場合は保存場所は同一にする必要有
    image.png

  • 更新時、ファイルサイズが同一になる場合は検知できない

詳細

フロー

  1. URL からファイルをアップロード で外部ファイルの取り込み
  2. パスを使用してファイル メタデータを取得 で以前のファイルの情報取得(ファイルサイズ)
  3. 以前と最新のファイルサイズを比較
  4. 通知
    image.png
  5. ファイルをコピーする 最新ファイルで以前のファイルを更新
    image.png

通知 Adaptive Card

通知
{
    "type": "AdaptiveCard",
    "$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
    "version": "1.4",
    "msteams": {
        "width": "full"
    },
    "body": [
        {
            "type": "TextBlock",
            "text": "ファイル更新通知",
            "wrap": true,
            "color": "Attention",
            "isSubtle": false
        },
        {
            "type": "TextBlock",
            "text": "ファイルが更新されました:Old File: @{outputs('Get_file_metadata_using_path')?['body/Size']} /sharepoint: @{outputs('Get_file_metadata')?['body/Size']}/New One: @{outputs('Upload_file_from_URL')?['body/Size']}",
            "wrap": true
        },
        {
            "type": "ActionSet",
            "actions": [
                {
                    "type": "Action.OpenUrl",
                    "url": "https://www.meti.go.jp/statistics/tyo/seidou/result/ichiran/08_seidou.html?pk_campaign=mm_statistics",
                    "iconUrl": "https://th.bing.com/th/id/R.3a646f7af36c19f92453a872e1a6a329?rik=NGLnMz%2bk6faQkw&riu=http%3a%2f%2fit.miami.edu%2f_assets%2fimages%2fO365_Power_BI.png&ehk=HBpjA2cY61UDu8947P%2f2Gm%2fB0yMsGkb7ZeS3AFO5hBs%3d&risl=&pid=ImgRaw&r=0",
                    "title": "更新されたと思うので確認しよう"
                }
            ]
        }
    ]
}

あとがき

あとは、定期動作させれば OK

keyword

how to detect file update in Power Automate

2
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1