question

MatteoS avatar image
0 Votes"
MatteoS asked ·

Azure policy: How to trigger evaluation manually

Dear all,
other than waiting 24hrs or make a little resource change that would trigger it within 15 minutes, do we have any way to trigger already applied policies evaluation?

This methodology that was working before now seems to be ignored.

 $subscriptionId = "SubscriptionID"
 $uri = "https://management.azure.com/subscriptions/$subscriptionId/providers/Microsoft.PolicyInsights/policyStates/latest/triggerEvaluation?api-version=2018-07-01-preview"
 $azContext = Get-AzContext
 $azProfile = [Microsoft.Azure.Commands.Common.Authentication.Abstractions.AzureRmProfileProvider]::Instance.Profile
 $profileClient = New-Object -TypeName Microsoft.Azure.Commands.ResourceManager.Common.RMProfileClient -ArgumentList ($azProfile)
 $token = $profileClient.AcquireAccessToken($azContext.Tenant.Id)
 $authHeader = @{
     'Content-Type'='application/json'
     'Authorization'='Bearer ' + $token.AccessToken
 }
 Invoke-RestMethod -Method Post -Uri $uri -UseBasicParsing -Headers $authHeader -Debug

Any advice on it would be great.

azure-policy
· 1
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

MatteoS avatar image
0 Votes"
MatteoS answered ·

Sorry about that,
my fault, it still works.

· Share
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.