AzurePowershellを利用して特定のタグが付与されたリソース名を取得してみました。
事前準備
AzurePowershellのインストール
Powershellを利用しますがその中でAzurePowershellを実行しますのでAzurePowershellモジュールが必要になります。
以下の記事にインストール方法を記載していますので必要であれば参考にしてください。

サービスプリンシパルの作成
Azureのリソースを操作するために今回はサービスプリンシパルを利用します。
以下の記事にサービスプリンシパルの作成方法を記載していますので必要であれば参考にしてください。

Powershellスクリプトファイルの作成
以下の内容でpowershellファイル(拡張子が ps1 となるファイル)を作成します。
・get-tag.ps1
#各情報が記載されたファイルから中身を読み取る
$ApplicationId = Get-Content C:\hogehoge\ApplicationId.txt
$Secret = Get-Content C:\hogehoge\Secret.txt
$tenantId = Get-Content C:\hogehoge\tenantId.txt
#クレデンシャルを作成する
$pw = ConvertTo-SecureString -String $Secret -AsPlainText -Force
$pscredential = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $ApplicationId, $pw
#ログインする
Connect-AzAccount -ServicePrincipal -Credential $pscredential -Tenant $tenantId
#特定のファイルに指定したタグのリソース名を取得してファイルに書き込む
(Get-AzResource -Tag @{ TAG="test" }).name | ConvertTo-Json | Out-File C:\hogehoge\tag_result.json -Encoding utf8 -Append
このスクリプトを実行することで、
「C:\hogehoge」配下にある「tag_result.json」ファイルに、「タグ名が[TAG]の中でタグの値が[test]であるリソース名」を追記する
という処理を実行することができます。
スクリプト内で利用するファイルを配置
「ApplicationId.txt」「Secret.txt」「tenantId.txt」を用意します。
今回は「C:\hogehoge」配下にそれぞれの値を記載し配置しました。
また今回は「get-tag.ps1」ファイルも「C:\hogehoge」に配置し、バッチファイルを起動してPowershellファイルを実行しています。
以下の記事にPowershellファイルをバッチで起動する方法を記載していますので必要であれば参考にしてください。

今回は「start.bat」というファイルを用意して、ps1ファイルを実行させます。
スクリプトを実行する
準備が終わり、ファイルが配置されたらバッチファイルを実行します。

バッチファイルが実行されるとコマンドプロンプトが起動し、ps1ファイルのスクリプトも実行されていきます。

実行が終わると、以下のように「tag_result.json」というファイルが作成され、その中に「タグ名が[TAG]の中でタグの値が[test]であるリソース名」が追記されます。
今回は2つのリソースがあることが確認できました。

手動で実行も可能
バッチファイルを実行するのでなく、Powershellのインターフェース上から上記のスクリプトを手動実行することも可能です。
ただし、その場合にはpowrshellの実行ポリシーには注意してください。
[参考] Tagで取得できる情報について
Azureのリソースにおいてタグが設定されている場合に、タグから取得できる情報には
「Name」「ResourceGroup」「ResourceType」「Location」「ResourceId」
などがあります。
この中から上記のスクリプトでは「Name」を取り出して、出力させてみました。
