Skip to content

Azure CLI wrapped with support for Service Principals

License

Notifications You must be signed in to change notification settings

darinegan/azure-cli-sp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Azure Client

The Microsoft Azure CLI Docker Image; wrapped with some added support for using a Service Principal.

Requirements

Usage

Invoke the following to start the Azure CLI.

.\setup.ps1

Login to the Azure CLI following any on-screen instructions to complete login.

az login

Once login is successful, a list of subscriptions associated with the account is displayed. Alternatively, you can execute the following Azure CLI command to verify.

az account list

Setting the Subscription ID

The subscription ID can be specified when the setup script is invoked.

.\setup.ps1 [[-SubscriptionID] <String>]

Otherwise, once logged in to the Azure CLI, select a subscription from the list associated with your account and set the subscription ID as follows.

export AZ_SUB_ID=$(az account list | jq -r .[0].id)

Creating a Service Principal

In order to create a Service Principal, the Path parameter must be specified when invoking the setup script. The Subscription ID can be specified as before.

The Path parameter references a text file which is written with the configuration values when the Service Principal is created.

.\setup.ps1 [[-SubscriptionID] <String>] [-Path <String>]

Once logged in, invoke the helper script as below to create a Service Principal with Contributor role associated with the specified subscription ID.

/root/aad_sp_init.sh create

When complete, the Service Principal configuration values are available within the container under the following path.

cat /root/rbac.json

[Optional] Login as Service Principal

If there is an existing Service Principal created previously, it is possible to login using this.

Invoke the setup script passing the Path parameter to the text file which contains the Service Principal configuration values when created.

.\setup.ps1 -Path <String>

Using the helper script, invoke this as follows to read the configuration values and login to the Azure CLI.

/root/aad_sp_init.sh read

Fin.

About

Azure CLI wrapped with support for Service Principals

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published