{"id":20463190,"url":"https://github.com/devwithkrishna/azure-automation-to-remove-policies-using-python","last_synced_at":"2026-04-12T03:03:50.606Z","repository":{"id":238503598,"uuid":"796696482","full_name":"devwithkrishna/azure-automation-to-remove-policies-using-python","owner":"devwithkrishna","description":"automation to remove policy from a subscription by name - especially tagging policies with subscription name and policy name as input","archived":false,"fork":false,"pushed_at":"2025-05-28T16:50:07.000Z","size":176,"stargazers_count":0,"open_issues_count":4,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-05-28T17:51:03.196Z","etag":null,"topics":["azure","azure-policy","github-workflow","python","python-sdk"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/devwithkrishna.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2024-05-06T13:05:37.000Z","updated_at":"2025-05-28T16:48:05.000Z","dependencies_parsed_at":"2024-06-26T16:10:57.203Z","dependency_job_id":"70b8f834-6ee0-45ab-9e0d-d0d6c7129948","html_url":"https://github.com/devwithkrishna/azure-automation-to-remove-policies-using-python","commit_stats":null,"previous_names":["devwithkrishna/azure-automation-to-remove-policies-using-python"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/devwithkrishna/azure-automation-to-remove-policies-using-python","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devwithkrishna%2Fazure-automation-to-remove-policies-using-python","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devwithkrishna%2Fazure-automation-to-remove-policies-using-python/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devwithkrishna%2Fazure-automation-to-remove-policies-using-python/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devwithkrishna%2Fazure-automation-to-remove-policies-using-python/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/devwithkrishna","download_url":"https://codeload.github.com/devwithkrishna/azure-automation-to-remove-policies-using-python/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devwithkrishna%2Fazure-automation-to-remove-policies-using-python/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":27559514,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-12-07T02:00:07.896Z","response_time":53,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["azure","azure-policy","github-workflow","python","python-sdk"],"created_at":"2024-11-15T13:09:48.182Z","updated_at":"2025-12-07T03:03:57.950Z","avatar_url":"https://github.com/devwithkrishna.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# azure-automation-to-remove-policies-using-python\nautomation to remove policy from a subscription by name - especially tagging policies with subscription name and policy name as input\n\n# References\n* https://learn.microsoft.com/en-us/python/api/azure-core/azure.core.exceptions.httpresponseerror?view=azure-python#azure-core-exceptions-httpresponseerror-message :heavy_check_mark:\n* https://learn.microsoft.com/en-us/python/api/azure-mgmt-resource/azure.mgmt.resource.policy.v2022_06_01.operations.policyassignmentsoperations?view=azure-python#azure-mgmt-resource-policy-v2022-06-01-operations-policyassignmentsoperations-delete :heavy_check_mark:\n* https://learn.microsoft.com/en-us/python/api/azure-mgmt-resource/azure.mgmt.resource.policy.v2022_06_01.policyclient?view=azure-python :heavy_check_mark: \n\n# What is azure policy\n\n```\nAzure Policy helps to enforce organizational standards and to assess compliance at-scale. \nThrough its compliance dashboard, it provides an aggregated view to evaluate the overall state of the environment,\nwith the ability to drill down to the per-resource, per-policy granularity. It also helps to bring your resources to compliance through bulk remediation for existing resources and automatic remediation for new resources.\n```\nRead more here: [Azure Governance - Policy](https://learn.microsoft.com/en-us/azure/governance/policy/overview)\n\n# What the code does\n\n```\nAs the name suggests, this is an automation to remove policy from a subscription by name especially tagging policies with subscription name and policy name as input\n```\n\n# Athentication \n\n```markdown\nAZURE_CLIENT_ID= \"xxxxxxxxxxx\"\nAZURE_CLIENT_SECRET = \"xxxxxxxxxxx\"\nAZURE_SUBSCRIPTION_ID = \"xxxxxxxxxxx\"\nAZURE_TENANT_ID = \"xxxxxxxxxxx\"\n```\n* Replace ` \"xxxxxxxxxxx\" ` with proper values\n\n**Rest is taken care by `DefaultAzureCredential` from `azure-identity` module** \n\n# How code works\n\n| file name | funtions |\n|-----------|----------|\n| azure_resource_graph_query.py | this file takes an argument, your subscription name and returns subscription id |\n| remove_azure_policy.py | this is the main py file. takes subscription id and policy name as inputs and removes policy if present |\n\n\nHow to run the program manually from cmd line:\n\n`python3 remove_azure_policy.py --subscription_name \"\u003cSubscription name\u003e\" --policy_name \"\u003cPolicy name\u003e\"`\n\n- replace the subscription name and policy names and provide correct values.\n\n# parameters \n\n`Python-dotenv reads key-value pairs from a .env file and can set them as environment variables`\n\n| input name      | type | description                                                 | required |\n|-----------------|------|-------------------------------------------------------------|----------|\n| subscription_name  | string | Azure subscription name. Default - `TECH-ARCHITECTS-NONPROD` | :heavy_check_mark: |\n| policy_name    | string | Azure policy to be removed.  | :heavy_check_mark: |\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevwithkrishna%2Fazure-automation-to-remove-policies-using-python","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdevwithkrishna%2Fazure-automation-to-remove-policies-using-python","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevwithkrishna%2Fazure-automation-to-remove-policies-using-python/lists"}