Azure Classroom Series – 26/Jun/2020

Azure SDK for Python

Installation and configuration

  1. Ensure Python 3 is installed
choco install python -y
  1. Configure Environment
    • Azure Account with Active Subscription
    • Python 3
    • Azure CLI Refer Here
  2. Configure Authentication and Authorization
    • Launch terminal and execute az login
    • Create a service principal and save the output to local-sp.jso
    az ad sp create-for-rbac --name localtest-sp-rbac --skip-assignment --sdk-aut > local-sp.json
    
    • Create environmental variables which Azure libraries require for authentication
    AZURE_SUBSCRIPTION_ID
    AZURE_TENANT_ID
    AZURE_CLIENT_ID
    AZURE_CLIENT_SECRET
    
    • For setting environmental variables in linux use export command and in cmd use set and in powershell $env:<VAR>='<value>'
  3. Install python Libraries Refer Here
  4. Packages and API Reference Refer Here
pip install azure-storage-blob
  1. API Reference for Azure Store blob package Refer Here
  2. Refer this example
  3. Sample code used in the class
from azure.common.client_factory import get_client_from_cli_profile
from azure.mgmt.resource import ResourceManagementClient

resource_client = get_client_from_cli_profile(ResourceManagementClient)
if resource_client.resource_groups.check_existence('frompython') == True:
    print('Resource group is already created')
else:
    rg_result = resource_client.resource_groups.create_or_update(
        "frompython",
        {
            "location": "centralus"
        }
    )
    print(rg_result)

Azure SDK for C#

Azure SDK for Java

Leave a Reply

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

Please turn AdBlock off
Plugin for Social Media by Acurax Wordpress Design Studio

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