LoginSignup
0
0

More than 1 year has passed since last update.

システム割り当てIDではなく、ユーザ割り当てIDを使ってKeyVaultにアクセスしたいときに使うコマンド

Posted at

システム割り当てIDではなく、ユーザー割り当てIDを使ってKeyVaultにアクセスしたいときに使うコマンド

通常AppServiceからKeyVaultの値を参照する場合、システム割り当てIDを使用してアクセスします。
しかし様々な理由のもと、システム割り当てマネージドIDではなく、ユーザー割り当てIDを使用したい場面があります。
その場合は、AppServiceに対してコマンドを実行し設定値を変更する必要があります。
なお、Azure Portal上のUIからは変更できないため、次のコマンドをCloud Shellなどを使用して実行します。

# リソースグループ名
$myResourceGroupName = ""
# 作成したマネージドIDのリソース名
$myAssignedIdentityName = ""
# ユーザー割り当てIDを使用したいAppService or Functionのリソース名
$myAppServiceName = ""

# それぞれのIDを取得
$userAssignedIdentityResourceId = Get-AzUserAssignedIdentity -ResourceGroupName $myResourceGroupName -Name $myAssignedIdentityName | Select-Object -ExpandProperty Id
$appResourceId = Get-AzFunctionApp -ResourceGroupName $myResourceGroupName -Name $myAppServiceName | Select-Object -ExpandProperty Id
$Path = "{0}?api-version=2021-01-01" -f $appResourceId

# プロパティを変更する
Invoke-AzRestMethod -Method PATCH -Path $Path -Payload "{'properties':{'keyVaultReferenceIdentity':'$userAssignedIdentityResourceId'}}"

参考

0
0
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
0
0