1
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サポートチケット関連APIを実行する

Posted at

Azureのサポートチケット関連操作をAPIで実行する必要があり、いくつかAPIを試したので書き残します。

アクセストークン取得

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

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

token=`az account get-access-token | jq -r .accessToken`

各種API操作

サポートチケット一覧取得

  • 以下コマンドでサポートチケット一覧を取得できます
curl -X GET -L -H "Content-Type: application/json" -H "Authorization: Bearer $token" https://management.azure.com/subscriptions/[Subscription ID]/providers/Microsoft.Support/supportTickets?api-version=2020-04-01 | jq .
  • 最も最近クローズになったサポートチケットのTicket Nameを取得します
curl -X GET -L -H "Content-Type: application/json" -H "Authorization: Bearer $token" https://management.azure.com/subscriptions/[Subscription ID]/providers/Microsoft.Support/supportTickets?api-version=2020-04-01 | jq -r '.value | map(select(.properties.status == "Closed")) | sort_by(.properties.modifiedDate) | reverse | .[0].name'

サポートチケットの詳細取得

  • 取得したTicket Nameを指定して、チケットの詳細を取得します
curl -X GET -L -H "Content-Type: application/json" -H "Authorization: Bearer $token" https://management.azure.com/subscriptions/[Subscription ID]/providers/Microsoft.Support/supportTickets/[Ticket Name]/communications?api-version=2020-04-01 | jq .
  • やり取りが長い場合はnextLinkが出力されるので続きを取得できます
curl -X GET -L -H "Content-Type: application/json" -H "Authorization: Bearer $token" https://management.azure.com/subscriptions/[Subscription ID]/providers/Microsoft.Support/supportTickets/[Ticket Name]/communications?api-version=2020-04-01 | jq -r .nextLink

curl -X GET -L -H "Content-Type: application/json" -H "Authorization: Bearer $token" '[nextLink]' | jq .

以上です

1
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
1
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?