Python Classroom notes 22/Sep/2024

Azure SDK for python

  • Refer Here for official docs
  • Python code to get list of resource groups

import os
from azure.identity import AzureCliCredential
from azure.mgmt.resource import ResourceManagementClient


def resource_group_list():
    """This method prints the resource groups
    """
    # in my machine there is already an environmental variable `ARM_SUBSCRIPTION_ID`
    subscription_id = os.getenv('ARM_SUBSCRIPTION_ID')
    credential = AzureCliCredential()
    resource_client = ResourceManagementClient(credential,subscription_id)
    names = list()
    for group in resource_client.resource_groups.list():
        names.append(group.name)
    print(names)

if __name__ == "__main__":
    #list resource groups
    resource_group_list()

Azure Functions

Published
Categorized as Uncategorized Tagged

By continuous learner

devops & cloud enthusiastic learner

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Please turn AdBlock off
Animated Social Media Icons by Acurax Responsive Web Designing Company

Discover more from Direct DevOps from Quality Thought

Subscribe now to keep reading and get access to the full archive.

Continue reading

Visit Us On FacebookVisit Us On LinkedinVisit Us On Youtube