2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Azure CLI を Git Bash で使う時の必須環境変数 MSYS_NO_PATHCONV

Posted at

MSYS_NO_PATHCONV が無いとどうなるのか

az resource show \
  --ids $(az group show \
  --name test-rg \
  --query id \
  --output tsv)

例えばリソースグループの情報を取得するような例では、/subscriptions の前に C:/Program Files/Git が勝手に追加されてしまい Azure CLI が正常に動作しません。

bash
az resource: error: argument --ids: invalid ResourceId value: 'C:/Program Files/Git/subscriptions/12345678-1234-1234-1234-123456789012/resourceGroups/test-rg'

これはスラッシュ / で始まる値をパスだと認識して自動的に Git Bash のパスを付加するデフォルトの仕様のようです。

MSYS_NO_PATHCONV=1 をつけて実行

bash
MSYS_NO_PATHCONV=1 az resource show \
  --ids $(az group show \
  --name test-rg \
  --query id \
  --output tsv)

下記のように正常に情報が取得できるようになりました。

bash
{
  "extendedLocation": null,
  "id": "/subscriptions/12345678-1234-1234-1234-123456789012/resourceGroups/test-rg",        
  "identity": null,
  "kind": null,
  "location": "japaneast",
  "managedBy": null,
  "name": "test-rg",
  "plan": null,
  "properties": {
    "provisioningState": "Succeeded"
  },
  "sku": null,
  "tags": {},
  "type": "Microsoft.Resources/resourceGroups"
}

毎回コマンドの前に入れるのが面倒なので私は、~/.profileexport MSYS_NO_PATHCONV=1 を設定しました。

参考

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?