Getting started - Managing Resource using Azure Python SDK

These samples will show you how to show to manage Resource using Azure Python SDK.


This project framework provides examples for the following services:


Getting Started


  1. Before we run the samples, we need to make sure we have setup the credentials. Follow the instructions in register a new application using Azure portal to obtain subscription id,client id,client secret, and application id

  2. Store your credentials an environment variables.
    For example, in Linux-based OS, you can do

export AZURE_TENANT_ID="xxx"
export AZURE_CLIENT_ID="xxx"
export SUBSCRIPTION_ID="xxx"


  1. If you don't already have it, install Python.

    This sample (and the SDK) is compatible with Python 2.7, 3.3, 3.4, 3.5 and 3.6.

  2. General recommendation for Python development is to use a Virtual Environment. For more information, see

    Install and initialize the virtual environment with the "venv" module on Python 3 (you must install virtualenv for Python 2.7):

    python -m venv mytestenv # Might be "python3" or "py -3.6" depending on your Python installation
    cd mytestenv
    source bin/activate      # Linux shell (Bash, ZSH, etc.) only
    ./scripts/activate       # PowerShell only
    ./scripts/activate.bat   # Windows CMD only


  1. Clone the repository.

    git clone
  2. Install the dependencies using pip.

    cd azure-samples-python-management/samples/resources
    pip install -r requirements.txt


A demo app is included to show how to use the project.

To run the complete demo, execute python

To run each individual demo, point directly to the file. For example (i.e. not complete list):

  1. python
  2. python

If you want to try async demo, you can run the demo in aio/ directory. It should be noted that it only works in python>=3.5.

  1. python aio/

If the script starts with disable_***.py, it means that it is unavailable now.

Each file is a separate code sample that no dependency on other files. You can look at whichever code sample you're interested in