Skip to content

Commit

Permalink
Merge pull request #445 from Banno/explicit-sub-no-use-default
Browse files Browse the repository at this point in the history
only use the default subscription if not set explicitly
  • Loading branch information
tombuildsstuff authored Nov 7, 2017
2 parents e9438c3 + d63c370 commit f751808
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions azurerm/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -255,13 +255,15 @@ 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
for _, subscription := range profile.Subscriptions {
if subscription.IsDefault {
c.SubscriptionID = subscription.ID
c.TenantID = subscription.TenantID
c.Environment = normalizeEnvironmentName(subscription.EnvironmentName)
break
// 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 {
c.SubscriptionID = subscription.ID
c.TenantID = subscription.TenantID
c.Environment = normalizeEnvironmentName(subscription.EnvironmentName)
break
}
}
}

Expand Down

0 comments on commit f751808

Please sign in to comment.