is there any rest api url for get all virtual machine compliance status?

151 views Asked by At

I am using this api url for getting virtual machine compliance status, however its giving me 202 Accepted response.

I have attached image for reference, I wanted to get these information through api.

2

1

There are 1 answers

0
Sridevi On

I tried to reproduce the same in my environment and got below results:

I created one Azure AD application named WebApp and granted API permission like below:

enter image description here

I generated access token via Postman with below parameters:

POST https://login.microsoftonline.com/<tenantID>/oauth2/v2.0/token

client_id: appID
grant_type: client_credentials
client_secret: secret
scope: https://management.azure.com/.default

Response:

enter image description here

Using above token, I too got same response like 202 Accepted while running the same query as you like below:

POST https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/assessPatches?api-version=2022-08-01

Response:

enter image description here

Currently, there is no such REST API query that can fetch you all virtual machine's compliance status. To confirm that, you can check this. Alternatively, you can make use of Kusto query.

I have below information on virtual machine's compliance status in my automation account:

enter image description here

To get this information from Kusto query, you need to follow below steps:

Go to Azure Portal -> Automation Accounts -> Select account -> Logs -> Azure Update Management -> Computers list -> Run

enter image description here

When I ran the query with scope as subscription, I got the results successfully like below:

enter image description here

Reference:

Retrieve azure update management status using REST API by VenkateshDodda-MSFT