func NewAzureProvider(configFile string, domainFilter DomainFilter, zoneIDFilter ZoneIDFilter, resourceGroup string, dryRun bool) (*AzureProvider, error) {
	contents, err := ioutil.ReadFile(configFile)
	if err != nil {
		return nil, fmt.Errorf("failed to read Azure config file '%s': %v", configFile, err)
	}
	cfg := config{}
	err = yaml.Unmarshal(contents, &cfg)
	if err != nil {
		return nil, fmt.Errorf("failed to read Azure config file '%s': %v", configFile, err)
	}

	// If a resource group was given, override what was present in the config file
	if resourceGroup != "" {
		cfg.ResourceGroup = resourceGroup
	}

	var environment azure.Environment
	if cfg.Cloud == "" {
		environment = azure.PublicCloud
	} else {
		environment, err = azure.EnvironmentFromName(cfg.Cloud)
		if err != nil {
			return nil, fmt.Errorf("invalid cloud value '%s': %v", cfg.Cloud, err)
		}
	}

	token, err := getAccessToken(cfg, environment)
	if err != nil {
		return nil, fmt.Errorf("failed to get token: %v", err)
	}

	zonesClient := dns.NewZonesClientWithBaseURI(environment.ResourceManagerEndpoint, cfg.SubscriptionID)
	zonesClient.Authorizer = autorest.NewBearerAuthorizer(token)
	recordsClient := dns.NewRecordSetsClientWithBaseURI(environment.ResourceManagerEndpoint, cfg.SubscriptionID)
	recordsClient.Authorizer = autorest.NewBearerAuthorizer(token)

	provider := &AzureProvider{
		domainFilter:  domainFilter,
		zoneIDFilter:  zoneIDFilter,
		dryRun:        dryRun,
		resourceGroup: cfg.ResourceGroup,
		zonesClient:   zonesClient,
		recordsClient: recordsClient,
	}
	return provider, nil
}
func NewAzureProvider(configFile string, domainFilter DomainFilter, zoneIDFilter ZoneIDFilter, resourceGroup string, dryRun bool) (*AzureProvider, error) {
	contents, err := ioutil.ReadFile(configFile)
	if err != nil {
		return nil, fmt.Errorf("failed to read Azure config file '%s': %v", configFile, err)
	}
	cfg := config{}
	err = yaml.Unmarshal(contents, &cfg)
	if err != nil {
		return nil, fmt.Errorf("failed to read Azure config file '%s': %v", configFile, err)
	}

	
	if resourceGroup != "" {
		cfg.ResourceGroup = resourceGroup
	}

	var environment azure.Environment
	if cfg.Cloud == "" {
		environment = azure.PublicCloud
	} else {
		environment, err = azure.EnvironmentFromName(cfg.Cloud)
		if err != nil {
			return nil, fmt.Errorf("invalid cloud value '%s': %v", cfg.Cloud, err)
		}
	}

	token, err := getAccessToken(cfg, environment)
	if err != nil {
		return nil, fmt.Errorf("failed to get token: %v", err)
	}

	zonesClient := dns.NewZonesClientWithBaseURI(environment.ResourceManagerEndpoint, cfg.SubscriptionID)
	zonesClient.Authorizer = autorest.NewBearerAuthorizer(token)
	recordsClient := dns.NewRecordSetsClientWithBaseURI(environment.ResourceManagerEndpoint, cfg.SubscriptionID)
	recordsClient.Authorizer = autorest.NewBearerAuthorizer(token)

	provider := &AzureProvider{
		domainFilter:  domainFilter,
		zoneIDFilter:  zoneIDFilter,
		dryRun:        dryRun,
		resourceGroup: cfg.ResourceGroup,
		zonesClient:   zonesClient,
		recordsClient: recordsClient,
	}
	return provider, nil
}
func NewAzureProvider ( configFile string , domainFilter DomainFilter , zoneIDFilter ZoneIDFilter , resourceGroup string , dryRun bool ) ( * AzureProvider , error ) { contents , err := ioutil . ReadFile ( configFile ) if err != nil { return nil , fmt . Errorf ( " " , configFile , err ) } cfg := config { } err = yaml . Unmarshal ( contents , & cfg ) if err != nil { return nil , fmt . Errorf ( " " , configFile , err ) } // If a resource group was given, override what was present in the config file if resourceGroup != " " { cfg . ResourceGroup = resourceGroup } var environment azure . Environment if cfg . Cloud == " " { environment = azure . PublicCloud } else { environment , err = azure . EnvironmentFromName ( cfg . Cloud ) if err != nil { return nil , fmt . Errorf ( " " , cfg . Cloud , err ) } } token , err := getAccessToken ( cfg , environment ) if err != nil { return nil , fmt . Errorf ( " " , err ) } zonesClient := dns . NewZonesClientWithBaseURI ( environment . ResourceManagerEndpoint , cfg . SubscriptionID ) zonesClient . Authorizer = autorest . NewBearerAuthorizer ( token ) recordsClient := dns . NewRecordSetsClientWithBaseURI ( environment . ResourceManagerEndpoint , cfg . SubscriptionID ) recordsClient . Authorizer = autorest . NewBearerAuthorizer ( token ) provider := & AzureProvider { domainFilter : domainFilter , zoneIDFilter : zoneIDFilter , dryRun : dryRun , resourceGroup : cfg . ResourceGroup , zonesClient : zonesClient , recordsClient : recordsClient , } return provider , nil }
// NewAzureProvider creates a new Azure provider.
//
// Returns the provider or an error if a provider could not be created.
NewAzureProvider creates a new Azure provider . Returns the provider or an error if a provider could not be created .