跳过导航

Hybrid-ResourceManager-Python-Manage-Resources

上次更新时间:2018/12/11
在 GitHub 上编辑

This sample explains how to manage your resources and resource groups in Azure Stack using the Azure Python SDK.

On this page

  • Run this sample
  • What is example.py doing?
    • List resource groups
    • Create a resource group
    • Update a resource group
    • Create a key vault in the resource group
    • List resources within the group
    • Export the resource group template
    • Delete a resource group

Run this sample

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

  2. We recommend to use a virtual environnement to run this example, but it's not mandatory. You can initialize a virtualenv this way:

    pip install virtualenv
    virtualenv mytestenv
    cd mytestenv
    source bin/activate
    
  3. Clone the repository.

    git clone https://github.com/Azure-Samples/Hybrid-ResourceManager-Python-Manage-Resources.git
    
  4. Install the dependencies using pip.

    cd Hybrid-ResourceManager-Python-Manage-Resources
    pip install -r requirements.txt
    
  5. Create a service principal to work against AzureStack. Make sure your service principal has contributor/owner role on your subscription.

  6. Export these environment variables into your current shell.

    export AZURE_RESOURCE_LOCATION={your resource location}
    export AZURE_TENANT_ID={your tenant id}
    export AZURE_CLIENT_ID={your client id}
    export AZURE_CLIENT_SECRET={your client secret}
    export AZURE_SUBSCRIPTION_ID={your subscription id}
    export ARM_ENDPOINT={your AzureStack Resource Manager Endpoint}
    
  7. Run the sample.

    python example.py