The request did not have a subscription or a valid tenant level resource provider. - facing this while creating policy. am i doing some mistake here?

Surakshit Sharma 26 Reputation points
2021-08-29T11:15:06.157+00:00

surakshit@Azure:~$ az policy assignment create --name 'audit-vm-manageddisks' --display-name 'Audit VMs without managed disks Assignment' --scope 'rg-test1' --policy '06a78e20-9358-41c9-923c-fb736d382a4d'
(MissingSubscription) The request did not have a subscription or a valid tenant level resource provider.
surakshit@Azure:~$

Azure Virtual Machines
Azure Virtual Machines
An Azure service that is used to provision Windows and Linux virtual machines.
7,101 questions
Azure Policy
Azure Policy
An Azure service that is used to implement corporate governance and standards at scale for Azure resources.
789 questions
0 comments No comments
{count} vote

Accepted answer
  1. prmanhas-MSFT 17,886 Reputation points Microsoft Employee
    2021-08-30T14:48:49.703+00:00

    @Surakshit Sharma Apologies for the delay in response and all the inconvenience caused because of the issue.

    Assuming from your query you might be following this .I tested same in my lab by creating new policy.

    First the policy definition will be as highlighted by running the command as mentioned in the article:

    az policy definition list --query "[?displayName=='Audit VMs that do not use managed disks']"

    127520-image.png

    Now I ran the above command as mentioned by you in the query which threw the same error as you :

    127631-image.png

    I did some digging and as per mentioned here defined policy scope as below we need to write the scope for resource group in below format:

    '/subscriptions/{SubscriptionID}/resourcegroups/{ResourceGroupName}'

    Again I ran the same command as mentioned by you and changed the scope as above where final command will look something like below and it worked for me :

    az policy assignment create --name 'audit-vm-manageddisks' --display-name 'Audit VMs without managed disks Assignment' --scope '/subscriptions/<Subscriptionid>/resourcegroups/prmanhas-Compute' --policy '06a78e20-9358-41c9-923c-fb736d382a4d'

    127596-image.png

    Same should work for you too :)

    Hope it helps!!!

    Please "Accept as Answer" if it helped so it can help others in community looking for help on similar topics.

    1 person found this answer helpful.
    0 comments No comments

0 additional answers

Sort by: Most helpful