'How do you check all the required resources in a RG exist?
On completion of an environment build, a colleague is manually going in to each Resource Group and checking the applicable resources have successfully created. We would like to automate this check to save time. We have been directed to use Azure Policy, which should flag up if a resource with a specific name hasn't been created.
Having checked the Azure Policy definition and having a bit of a play about in the Portal, it seems we're potentially looking at the incorrect resource (i.e. Policy). If this is possible in policy, is there a way in which we could do this without creating numerous policies/initiatives?
i.e. I want to check example-resource-group-1-rg has at least the following resources: example-webapp-name example-apim-name example-logicapp-name
Solution 1:[1]
In Azure Policy there are several policies through which you can access resources on basis of some condition.
Allow Resource Type: It defines what type of resource you can deploy
Allowed Location: Restrict the available location for new resources
Add a tag to resources: Applies a required tag and its default value if it's not specified by the deploy request
Not allowed resource types: It prevent list of resource types from being deployed.
you can apply such type of policies using azure portal.
Azure policy is use for implementing governance for resources consistency, regulatory compliance, security, cost, and management. azure policy valuates the resources to business rules according to their properties. Azure policy uses JSON format to create a logic and evaluate those resources is competent or not policy rule determines resources is competent or not definition include metadata and use function, parameter and logical operator During resources lifecycle resources are evaluated given events determines evaluation of resources
A policy is newly assigned to a scope.
If a policy is already updated which is assigned to a scope.
A resource is updated or created in a scope with policy assignment.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | SaiSakethGuduru-MT |