page_type | languages | products | description | urlFragment | ||
---|---|---|---|---|---|---|
sample |
|
|
samples to demonstrate various interaction with azure stack using azure python SDK. |
Hybrid-Python-Samples |
This repository is for Azure Stack Hub python sdk samples. Each of the sub-directories contain README.md files detailing how to run that sample.
Prerequisites Refer to this azure stack doc for more information: https://docs.microsoft.com/en-us/azure-stack/user/azure-stack-version-profiles-python
-
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-Python-Samples.git
-
From the root of this repository, install the dependencies using pip.
pip install -r requirements.txt
-
Create a service principal to work against Azure Stack. Make sure your service principal has contributor/owner role on your subscription.
-
Make a copy of
azureSecretSpConfig.json.dist
andazureCertSpConfig.json.dist
, then rename those copies toazureSecretSpConfig.json
andazureCertSpConfig.json
(whichever is needed). -
Set the following JSON properties in ./azureSecretSpConfig.json.
Variable Description clientId
Service principal application id. clientSecret
Service principal application secret. tenantId
Azure Stack Hub tenant id. objectId
Service principal object id. subscriptionId
Subscription id used to access offers in Azure Stack Hub. resourceManagerEndpointUrl
Azure Stack Hub Resource Manager Endpoint. location
Azure Resource location. -
Run the sample within each individual sample folders with the following:
python example.py