Azure SDK for Python
Installation and configuration
- Ensure Python 3 is installed
choco install python -y
- Configure Environment
- Azure Account with Active Subscription
- Python 3
- Azure CLI Refer Here
- 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>'
- Install python Libraries Refer Here
- Packages and API Reference Refer Here
pip install azure-storage-blob
- API Reference for Azure Store blob package Refer Here
- Refer this example
- 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
Like this:
Like Loading...