Pomiń nawigację

Hybrid-Storage-Python-Manage-Storage-Account

Ostatnia aktualizacja: 12.12.2018
Edytuj w witrynie GitHub

This sample shows how to manage your storage account using the Azure Storage Management package for Python. The Storage Resource Provider is a client library for working with the storage accounts in your Azure subscription. Using the client library, you can create a new storage account, read its properties, list all storage accounts in a given subscription or resource group, read and regenerate the storage account keys, and delete a storage account.

On this page

  • Run this sample
  • What is example.py doing?
    • Check storage account name availability
    • Create a new storage account
    • Get the properties of an account
    • List storage accounts
    • List storage accounts by resource group
    • Get the storage account keys
    • Regenerate a storage account key
    • Delete a storage account
    • Usage

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-Storage-Python-Manage-Storage-Account.git
    
  4. Install the dependencies using pip.

    cd Hybrid-Storage-Python-Manage-Storage-Account
    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