1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85
|
# Test Azure Identity in Azure Cloud Shell
# Open Azure Cloud Shell
https://shell.azure.com/
# Create an Azure Key Vault
## Set environment variables to simplify copy-pasting
- RESOURCE_GROUP
- name of an Azure resource group
- must be unique in the Azure subscription
- e.g. 'cloudshell-identity-test'
- KEY_VAULT_NAME
- 3-24 alphanumeric characters
- must begin with a letter
- must be globally unique
## Create a resource group
```sh
az group create -n $RESOURCE_GROUP --location westus2
```
## Create the key vault
```sh
az keyvault create -g $RESOURCE_GROUP -n $KEY_VAULT_NAME --sku standard
```
The tests expect the vault's URI in an environment variable:
```sh
export AZURE_IDENTITY_TEST_VAULT_URL=$(az keyvault show -g $RESOURCE_GROUP -n $KEY_VAULT_NAME --query properties.vaultUri | tr -d '"')
```
# Run the tests
## Acquire the latest code
This may take several minutes:
```sh
git clone https://github.com/azure/azure-sdk-for-python --single-branch --branch main --depth 1
```
## Change working directory
```sh
cd azure-sdk-for-python/sdk/identity/azure-identity
```
## Create virtual environment
The Azure SDK supports Python 3.8+. Python 3 should be installed in your Cloud Shell.
```sh
python -m venv ~/venv
```
## Activate virtual environment
For example:
```sh
source ~/venv/bin/activate
```
## Install packages
```sh
pip install -r dev_requirements.txt .
```
## Set required environment variables
```sh
export AZURE_TEST_RUN_LIVE=true
export AZURE_SKIP_LIVE_RECORDING=true
```
## Run tests
```sh
pytest ./tests -vrs -m cloudshell
```
# Clean up
## Deactivate virtual environment
```sh
deactivate
```
## Delete Azure resources
After running tests, delete the resources provisioned earlier:
```sh
az group delete -n $RESOURCE_GROUP -y --no-wait
```
|