Bagikan melalui


Melacak operasi asinkron menggunakan Azure CLI

Beberapa operasi Azure CLI bersifat asinkron. Untuk melacak status operasi asinkron, operationStatuses sumber daya dapat digunakan. Perintah asinkron dapat dijalankan dengan --debug bendera diaktifkan. Ketika --debug ditentukan, kemajuan permintaan dapat dipantau. URL status operasi dapat ditemukan dengan memeriksa Azure-AsyncOperation header atau Location pada respons HTTP terhadap permintaan pembuatan.

... many lines of logged information ...

urllib3.connectionpool: https://management.azure.com:443 "PUT /subscriptions/.../resourceGroups/.../providers/Microsoft.NetworkCloud/clusters/.../metricsConfigurations/default?api-version=2022-12-12-preview HTTP/1.1" 201 926
cli.azure.cli.core.util: Response status: 201
cli.azure.cli.core.util: Response headers:

... several lines of http headers of the response ...

cli.azure.cli.core.util:     'Azure-AsyncOperation': 'https://management.azure.com/subscriptions/.../providers/Microsoft.NetworkCloud/locations/EASTUS/operationStatuses/12312312-1231-1231-1231-123123123123*99399E995...?api-version=2022-12-12-preview'

... remaining http headers of the response and more lines of logging ...

Menggunakan nilai dari sebelumnya: https://management.azure.com/subscriptions/.../providers/Microsoft.NetworkCloud/locations/EASTUS/operationStatuses/12312312-1231-1231-1231-123123123123*99399E995...?api-version=2022-12-12-preview, panggilan Azure CLI az rest dapat dikeluarkan untuk mengambil status operasi.

az rest -m get -u "https://management.azure.com/subscriptions/.../providers/Microsoft.NetworkCloud/locations/EASTUS/operationStatuses/12312312-1231-1231-1231-123123123123*99399E995...?api-version=2022-12-12-preview"

Permintaan ini akan mengembalikan hasil status operasi yang dapat dikueri ulang menggunakan perintah yang sama hingga status mencapai status Succeeded akhir atau Failed. Pada titik ini, operasi yang diminta telah berhenti.

{
  "endTime": "2023-02-08T17:38:31.2042934Z",
  "error": {},
  "id": "subscriptions/.../providers/Microsoft.NetworkCloud/locations/EASTUS/operationStatuses/12312312-1231-1231-1231-123123123123*99399E995...?api-version=2022-12-12-preview",
  "name": "12312312-1231-1231-1231-123123123123*99399E995...",
  "properties": null,
  "resourceId": "subscriptions/.../resourceGroups/.../providers/Microsoft.NetworkCloud/clusters/.../metricsConfigurations/default?api-version=2022-12-12-preview",
  "startTime": "2023-02-08T17:38:24.7576911Z",
  "status": "Succeeded"
}