Azure accounts can be referenced in a project through a project variable of the type Azure account.
The Azure PowerShell step will allow you to bind the account to an Azure account variable, using the binding syntax. By using an variable for the account, you can have different accounts used across different environments or regions using scoping.
The Add Variable window is then displayed and lists all the Azure accounts.
Select the account that was created in the previous step to assign it to the variable.
Azure account variable properties
The Azure account Variable also exposes the following properties that you can reference in a PowerShell script:
Service Principal
Name and description | Example |
---|---|
SubscriptionNumber The Azure Subscription Id | cd21dc34-73dc-4c7d-bd86-041284e0bc45 |
Client The Azure Application Id | 57dfa713-f4c1-4b15-b21d-d14ff7941f7c |
Password | correct horse battery staple |
TenantId The Azure Active Directory Tenant Id | 2a681dca-3230-4e01-abcb-b1fd225c0982 |
AzureEnvironment The Azure environment | AzureCloud, AzureGermanCloud, AzureChinaCloud, AzureUSGovernment |
ResourceManagementEndpointBaseUri Only set if explicitly set in the Account settings | https://management.microsoftazure.de/ |
ActiveDirectoryEndpointBaseUri Only set if explicitly set in the Account settings | https://login.microsoftonline.de/ |
Management certificate
Name and description | Example |
---|---|
SubscriptionNumber The Azure Subscription Id | cd21dc34-73dc-4c7d-bd86-041284e0bc45 |
CertificateThumbprint The thumbprint of the certificate | |
ServiceManagementEndpointBaseUri | https://management.core.cloudapi.de |
ServiceManagementEndpointSuffix | core.cloudapi.de |
AzureEnvironment The Azure environment | AzureCloud, AzureGermanCloud, AzureChinaCloud, AzureUSGovernment |
Accessing the properties in a script
Each of the above properties can be referenced in any of the supported scripting languages such as PowerShell and Bash.
PowerShell
# For an account with a variable name of 'azure account'
# Using $OctopusParameters
Write-Host 'AzureAccount.Id=' $OctopusParameters["azure account"]
Write-Host 'AzureAccount.Client=' $OctopusParameters["azure account.Client"]
# Directly as a variable
Write-Host 'AzureAccount.Id=' $azureAccount
Write-Host 'AzureAccount.Client=' $azureAccountClient
Bash
# For an account with a variable name of 'azure account'
id=$(get_octopusvariable "azure account")
client=$(get_octopusvariable "azure account.Client")
echo "Azure Account Id is: $id"
echo "Azure Account Client is: $client"
Learn more
Help us continuously improve
Please let us know if you have any feedback about this page.
Page updated on Thursday, August 29, 2024