Skip to content

Commit

Permalink
provider/azurerm: use configured environment for storage clients (#11159
Browse files Browse the repository at this point in the history
)

This fixes storage related operations for all environments outside of the public
Azure cloud, tested by deploying all storage resources in a German subscription.
  • Loading branch information
pmcatominey authored and stack72 committed Jan 17, 2017
1 parent 061925f commit d97f7e5
Showing 1 changed file with 17 additions and 11 deletions.
28 changes: 17 additions & 11 deletions builtin/providers/azurerm/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ type ArmClient struct {
clientId string
tenantId string
subscriptionId string
environment azure.Environment

StopContext context.Context

Expand Down Expand Up @@ -131,13 +132,6 @@ func setUserAgent(client *autorest.Client) {
// getArmClient is a helper method which returns a fully instantiated
// *ArmClient based on the Config's current settings.
func (c *Config) getArmClient() (*ArmClient, error) {
// client declarations:
client := ArmClient{
clientId: c.ClientID,
tenantId: c.TenantID,
subscriptionId: c.SubscriptionID,
}

// detect cloud from environment
env, envErr := azure.EnvironmentFromName(c.Environment)
if envErr != nil {
Expand All @@ -149,6 +143,14 @@ func (c *Config) getArmClient() (*ArmClient, error) {
}
}

// client declarations:
client := ArmClient{
clientId: c.ClientID,
tenantId: c.TenantID,
subscriptionId: c.SubscriptionID,
environment: env,
}

rivieraClient, err := riviera.NewClient(&riviera.AzureResourceManagerCredentials{
ClientID: c.ClientID,
ClientSecret: c.ClientSecret,
Expand Down Expand Up @@ -470,7 +472,8 @@ func (armClient *ArmClient) getBlobStorageClientForStorageAccount(resourceGroupN
return nil, false, nil
}

storageClient, err := mainStorage.NewBasicClient(storageAccountName, key)
storageClient, err := mainStorage.NewClient(storageAccountName, key, armClient.environment.StorageEndpointSuffix,
mainStorage.DefaultAPIVersion, true)
if err != nil {
return nil, true, fmt.Errorf("Error creating storage client for storage account %q: %s", storageAccountName, err)
}
Expand All @@ -488,7 +491,8 @@ func (armClient *ArmClient) getFileServiceClientForStorageAccount(resourceGroupN
return nil, false, nil
}

storageClient, err := mainStorage.NewBasicClient(storageAccountName, key)
storageClient, err := mainStorage.NewClient(storageAccountName, key, armClient.environment.StorageEndpointSuffix,
mainStorage.DefaultAPIVersion, true)
if err != nil {
return nil, true, fmt.Errorf("Error creating storage client for storage account %q: %s", storageAccountName, err)
}
Expand All @@ -506,7 +510,8 @@ func (armClient *ArmClient) getTableServiceClientForStorageAccount(resourceGroup
return nil, false, nil
}

storageClient, err := mainStorage.NewBasicClient(storageAccountName, key)
storageClient, err := mainStorage.NewClient(storageAccountName, key, armClient.environment.StorageEndpointSuffix,
mainStorage.DefaultAPIVersion, true)
if err != nil {
return nil, true, fmt.Errorf("Error creating storage client for storage account %q: %s", storageAccountName, err)
}
Expand All @@ -524,7 +529,8 @@ func (armClient *ArmClient) getQueueServiceClientForStorageAccount(resourceGroup
return nil, false, nil
}

storageClient, err := mainStorage.NewBasicClient(storageAccountName, key)
storageClient, err := mainStorage.NewClient(storageAccountName, key, armClient.environment.StorageEndpointSuffix,
mainStorage.DefaultAPIVersion, true)
if err != nil {
return nil, true, fmt.Errorf("Error creating storage client for storage account %q: %s", storageAccountName, err)
}
Expand Down

0 comments on commit d97f7e5

Please sign in to comment.