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.

毎回忘れちゃうので自分用メモとして残します。

Cloud Shell(Bash)

  • Azure PortalにログインしてCloud Shell(Bash)を開きます。

  • アクセストークンを取得します。

token=`az account get-access-token | jq -r .accessToken`
  • 対象のREST APIを実行します(ここでは例としてリソースグループ一覧を取得しています)
curl -X GET -L -H "Content-Type: application/json" -H "Authorization: Bearer $token" https://management.azure.com/subscriptions/[Subsciption Id]/resourcegroups?api-version=2021-04-01 | jq .

Azure CLI(ローカル実行)

  • ここではWindowsPCでの実行を想定しています。まずはPowerShellを開きます。

  • Azureにログインします。

az login
  • アクセストークンを取得します。
$token = az account get-access-token | ConvertFrom-Json
$token = $token.accessToken
  • 対象のREST APIを実行します(ここでは例としてリソースグループ一覧を取得しています)
$res = Invoke-WebRequest -Method GET -Headers @{"Content-Type"="application/json"; "Authorization"="Bearer $token"} https://management.azure.com/subscriptions/[Subsciption Id]/resourcegroups?api-version=2021-04-01
ConvertFrom-Json $res.Content | ConvertTo-Json

以上です

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?