Using Console
Using CLI
<alert-name>
and <alert-description>
with a name and description for your alert, <threshold>
with the number of subscription owners that triggers the alert, <subscription-id>
with the ID of your subscription, and <email-address>
with the email address to which notifications should be sent.
This command creates an alert rule that monitors the “total subscription owners” metric for your subscription, evaluates it every minute, and sends an email notification if the threshold is exceeded.
Using Python
ResourceManagementClient
is used to interact with the Azure Resource Manager API. The providers.get
method is used to get the role assignments for the Microsoft.Authorization provider. The properties.permissions
attribute contains the list of permissions for the provider. The actions
attribute contains the list of actions that can be performed on the resource. The notActions
attribute contains the list of actions that cannot be performed on the resource. The dataActions
attribute contains the list of data actions that can be performed on the resource. The notDataActions
attribute contains the list of data actions that cannot be performed on the resource. Finally, the principalIds
attribute contains the list of principal IDs for the role assignment.Step 4: Remediate the IssueTo remediate the issue, you need to ensure that there are no more than two subscription owners. If there are more than two subscription owners, you can remove the excess owners. Here’s an example code snippet: