code: func (d *Driver) newAzureClient() (*azureutil.AzureClient, error) {
  	env, ok := environments[d.Environment]
  	if !ok {
  		valid := make([]string, 0, len(environments))
  		for k := range environments {
  			valid = append(valid, k)
  		}
  
  		return nil, fmt.Errorf("Invalid Azure environment: %q, supported values: %s", d.Environment, strings.Join(valid, ", "))
  	}
  
  	var (
  		token *azure.ServicePrincipalToken
  		err   error
  	)
  	if d.ClientID != "" && d.ClientSecret != "" { // use Service Principal auth
  		log.Debug("Using Azure service principal authentication.")
  		token, err = azureutil.AuthenticateServicePrincipal(env, d.SubscriptionID, d.ClientID, d.ClientSecret)
  		if err != nil {
  			return nil, fmt.Errorf("Failed to authenticate using service principal credentials: %+v", err)
  		}
  	} else { // use browser-based device auth
  		log.Debug("Using Azure device flow authentication.")
  		token, err = azureutil.AuthenticateDeviceFlow(env, d.SubscriptionID)
  		if err != nil {
  			return nil, fmt.Errorf("Error creating Azure client: %v", err)
  		}
  	}
  	return azureutil.New(env, d.SubscriptionID, token), nil
  }
docs: // newAzureClient creates an AzureClient helper from the Driver context and
  // initiates authentication if required.