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 comment

Turn on JavaScript to leave a comment.

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

Please turn AdBlock off
Social Media Icons Powered by Acurax Web Design Company
Exit mobile version
%%footer%%