The first thing you need to set up is your credentials, that are also used to define where the infrastructure changes will be applied.
We have a tools to make this easier, its output can be used to set environment variables on a easy way for you.
It is a good idea to save this env vars on a safe place on your host to make your life easier.
Before anything, you must be logged before creating a service principal. If you want to avoid installing all the depencies to work with azure on your host just run:
make shell
And inside the provided shell run:
azure login
Now that you are logged, first you need to define in which subscription you want to create it.
To know which subscriptions are available for your user run:
azure account list
You will need the name of the subscription for the next step. When you have the subscription name just run:
./tools/azure/createsp.sh <subscription-name> <service-principal-name> <password>
If it executes with success you will have a valid service principal to start having some fun at Azure.
If you already have a service principal
configured, you can setup
the environment variables using the getcredentials.sh
script.
You'll need the environment variables below:
- AZURE_SUBSCRIPTION_ID=<subscription id>
- AZURE_TENANT_ID=<tenant id>
- AZURE_CLIENT_ID=<AppId of service principal>
- AZURE_CLIENT_SECRET=<password of service principal>
Basic usage:
make credentials sh=(sh|nash) subscription=(subscription) service-principal=(sp name) service-secret=(secret)
For cool nash shells:
make credentials "sh=nash" "subscription=subscription-name" "service-principal=klb-sp-tests" "service-secret=123456"
setenv AZURE_SUBSCRIPTION_ID="XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXXXXX"
setenv AZURE_SUBSCRIPTION_NAME="CLOUDFORMATION - QA"
setenv AZURE_TENANT_ID="XXXXXXXX-XXXX-XXXX-XXXXXXXXXXXXXX"
setenv AZURE_CLIENT_ID="XXXXXXXX-XXXX-XXXX-XXXXXXXXXXXXXX"
setenv AZURE_CLIENT_SECRET="123456"
Copy the environment variables from the output to a file and import into your nash session:
λ> import ./credentials
For lame linux shell (like bash):
make credentials sh=sh subscription=subscription-name service-principal=klb-sp-tests service-secret=123456
export AZURE_SUBSCRIPTION_ID="XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXXXXX"
export AZURE_SUBSCRIPTION_NAME="CLOUDFORMATION - QA"
export AZURE_TENANT_ID="XXXXXXXX-XXXX-XXXX-XXXXXXXXXXXXXX"
export AZURE_CLIENT_ID="XXXXXXXX-XXXX-XXXX-XXXXXXXXXXXXXX"
export AZURE_CLIENT_SECRET="123456"
Write the output above to a file and import into your lame shell session:
λ> source ./credentials
Besides the credential your subscription must also be registered on some resource provider namespaces, since we will be creating resources.
To register on the required providers you can run:
λ> ./tools/azure/registerproviders.sh
There are some examples on the examples/azure dir. To build them you can call:
make example-<name>
Where can be the name of any example on the dir.
Running the backup example:
make example-backup