page_type | languages | products | description | urlFragment | ||
---|---|---|---|---|---|---|
sample |
|
|
This sample explains how to manage your resources and resource groups in Azure Stack using the Azure Python SDK. |
Hybrid-ResourceManager-Python-Manage-Resources |
Hybrid-ResourceManager-Python-Manage-Resources
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
-
If you don't already have it, install Python.
-
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
-
Clone the repository.
git clone https://github.com/Azure-Samples/Hybrid-ResourceManager-Python-Manage-Resources.git
-
Install the dependencies using pip.
cd Hybrid-ResourceManager-Python-Manage-Resources pip install -r requirements.txt
-
Create a service principal to work against AzureStack. Make sure your service principal has contributor/owner role on your subscription.
-
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}
-
Run the sample.
python example.py