Environment for working with Azure VCFs
-
Ensure Python 3.8+ is installed on your system
-
Create an Azure Active Directory application (or request on be created)
-
Create a secret for the application
-
Create a resource group
-
Assign the application to the Contributor or Reader role on the resource group (Request permission if you are not authorized to assign roles on the resource group)
-
In
.vscode/launch.json
fill in theAZURE_CLIENT_ID
andAZURE_CLIENT_SECRET
for the VCF user. Be sure to escape the JSON. Avoid using online tools to do this due to the sensitive nature of what you are escaping. The resultingenv
map will resemble:{ "AZURE_SUBSCRIPTION_ID": "12345678-1234-1234-1234-123456789012", "AZURE_CLIENT_ID": "abcdefab-abcd-abcd-abcd-abcdefabcdef", "AZURE_CLIENT_SECRET": "AL8)RxYQzCf./dF!y5EN13eqdg3T!qwh", "AZURE_TENANT_ID": "1234abcd-1234-1234-1234-1234abcd1234", "AZURE_RESOURCE_GROUP": "your-resource-group" }
-
In
init.sh
(Mac/Linux)/init.ps1
(Windows) replace YOUR_BITBUCKET_USER with the name of your Cloud Academy BitBucket user -
Run
init.sh
(Mac/Linux)/init.ps1
(Windows) to set up the environment- Enter your Cloud Academy BitBucket password/app password when prompted.
-
Add the following line to
.gitignore
to avoid committing any sensitive information:.vscode/
-
Develop and debug functions using the
Current File (Integrated Terminal)
configuration (press F5 with the file open)
- Run
init.sh
(Mac/Linux)/init.ps1
(Windows) to set up the virtual environment again. (only thevenv/
directory is impacted by this operation)
-
Add the package including version to the
requirements.txt
file -
Run the following to remove the existing virtual environment and install only the production dependencies in a clean environment:
rm -rf venv # clean start python3 -m venv venv source ./venv/bin/activate pip install -r requirements.txt # prod dependencies
-
Freeze the prod dependencies into
requirements.txt
:pip freeze > requirements.txt
-
Add in the dev dependencies
pip install pylint autopep8 # dev dependencies
-
Run the code below the
# Trim Azure mgmt packages included api versions
comment ininit.sh
to trim the API versions of the Azure management clients to reduce the disk space (lambda layers have only ~256MB available). -
Test your check functions are working after trimming and create a pull request on bitbucket labs-vcf-boilerplates with the new
requirements.txt
- Azure SDK for Python (Unit test code in particular)