Skip to content

Commit

Permalink
Conditional loading of the Subscription ID / Tenant ID / Environment
Browse files Browse the repository at this point in the history
  • Loading branch information
tombuildsstuff committed Nov 30, 2017
1 parent 61b1671 commit cd6457b
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions azurerm/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -257,15 +257,19 @@ func (c *Config) LoadTokensFromAzureCLI() error {
return fmt.Errorf("Azure CLI Authorization Profile was not found. Please ensure the Azure CLI is installed and then log-in with `az login`.")
}

// pull out the TenantID and Subscription ID from the Azure Profile, if not set
if c.SubscriptionID == "" && c.TenantID == "" {
for _, subscription := range profile.Subscriptions {
if subscription.IsDefault {
// pull out the Subscription ID / Tenant ID / Environment from the Azure Profile, if not set
for _, subscription := range profile.Subscriptions {
if subscription.IsDefault {
if c.SubscriptionID == "" {
c.SubscriptionID = subscription.ID
}
if c.TenantID == "" {
c.TenantID = subscription.TenantID
}
if c.Environment == "" {
c.Environment = normalizeEnvironmentName(subscription.EnvironmentName)
break
}
break
}
}

Expand Down

0 comments on commit cd6457b

Please sign in to comment.