github.com/vtorhonen/terraform@v0.9.0-beta2.0.20170307220345-5d894e4ffda7/builtin/providers/azurerm/config.go (about) 1 package azurerm 2 3 import ( 4 "context" 5 "fmt" 6 "log" 7 "net/http" 8 "net/http/httputil" 9 10 "github.com/Azure/azure-sdk-for-go/arm/cdn" 11 "github.com/Azure/azure-sdk-for-go/arm/compute" 12 "github.com/Azure/azure-sdk-for-go/arm/containerregistry" 13 "github.com/Azure/azure-sdk-for-go/arm/containerservice" 14 "github.com/Azure/azure-sdk-for-go/arm/eventhub" 15 "github.com/Azure/azure-sdk-for-go/arm/keyvault" 16 "github.com/Azure/azure-sdk-for-go/arm/network" 17 "github.com/Azure/azure-sdk-for-go/arm/redis" 18 "github.com/Azure/azure-sdk-for-go/arm/resources/resources" 19 "github.com/Azure/azure-sdk-for-go/arm/scheduler" 20 "github.com/Azure/azure-sdk-for-go/arm/servicebus" 21 "github.com/Azure/azure-sdk-for-go/arm/storage" 22 "github.com/Azure/azure-sdk-for-go/arm/trafficmanager" 23 mainStorage "github.com/Azure/azure-sdk-for-go/storage" 24 "github.com/Azure/go-autorest/autorest" 25 "github.com/Azure/go-autorest/autorest/azure" 26 "github.com/hashicorp/terraform/terraform" 27 riviera "github.com/jen20/riviera/azure" 28 ) 29 30 // ArmClient contains the handles to all the specific Azure Resource Manager 31 // resource classes' respective clients. 32 type ArmClient struct { 33 clientId string 34 tenantId string 35 subscriptionId string 36 environment azure.Environment 37 38 StopContext context.Context 39 40 rivieraClient *riviera.Client 41 42 availSetClient compute.AvailabilitySetsClient 43 usageOpsClient compute.UsageClient 44 vmExtensionImageClient compute.VirtualMachineExtensionImagesClient 45 vmExtensionClient compute.VirtualMachineExtensionsClient 46 vmScaleSetClient compute.VirtualMachineScaleSetsClient 47 vmImageClient compute.VirtualMachineImagesClient 48 vmClient compute.VirtualMachinesClient 49 50 appGatewayClient network.ApplicationGatewaysClient 51 ifaceClient network.InterfacesClient 52 loadBalancerClient network.LoadBalancersClient 53 localNetConnClient network.LocalNetworkGatewaysClient 54 publicIPClient network.PublicIPAddressesClient 55 secGroupClient network.SecurityGroupsClient 56 secRuleClient network.SecurityRulesClient 57 subnetClient network.SubnetsClient 58 netUsageClient network.UsagesClient 59 vnetGatewayConnectionsClient network.VirtualNetworkGatewayConnectionsClient 60 vnetGatewayClient network.VirtualNetworkGatewaysClient 61 vnetClient network.VirtualNetworksClient 62 vnetPeeringsClient network.VirtualNetworkPeeringsClient 63 routeTablesClient network.RouteTablesClient 64 routesClient network.RoutesClient 65 66 cdnProfilesClient cdn.ProfilesClient 67 cdnEndpointsClient cdn.EndpointsClient 68 69 containerRegistryClient containerregistry.RegistriesClient 70 containerServicesClient containerservice.ContainerServicesClient 71 72 eventHubClient eventhub.EventHubsClient 73 eventHubConsumerGroupClient eventhub.ConsumerGroupsClient 74 eventHubNamespacesClient eventhub.NamespacesClient 75 76 providers resources.ProvidersClient 77 resourceGroupClient resources.GroupsClient 78 tagsClient resources.TagsClient 79 resourceFindClient resources.GroupClient 80 81 jobsClient scheduler.JobsClient 82 jobsCollectionsClient scheduler.JobCollectionsClient 83 84 storageServiceClient storage.AccountsClient 85 storageUsageClient storage.UsageOperationsClient 86 87 deploymentsClient resources.DeploymentsClient 88 89 redisClient redis.GroupClient 90 91 trafficManagerProfilesClient trafficmanager.ProfilesClient 92 trafficManagerEndpointsClient trafficmanager.EndpointsClient 93 94 serviceBusNamespacesClient servicebus.NamespacesClient 95 serviceBusTopicsClient servicebus.TopicsClient 96 serviceBusSubscriptionsClient servicebus.SubscriptionsClient 97 98 keyVaultClient keyvault.VaultsClient 99 } 100 101 func withRequestLogging() autorest.SendDecorator { 102 return func(s autorest.Sender) autorest.Sender { 103 return autorest.SenderFunc(func(r *http.Request) (*http.Response, error) { 104 // dump request to wire format 105 if dump, err := httputil.DumpRequestOut(r, true); err == nil { 106 log.Printf("[DEBUG] AzureRM Request: \n%s\n", dump) 107 } else { 108 // fallback to basic message 109 log.Printf("[DEBUG] AzureRM Request: %s to %s\n", r.Method, r.URL) 110 } 111 112 resp, err := s.Do(r) 113 if resp != nil { 114 // dump response to wire format 115 if dump, err := httputil.DumpResponse(resp, true); err == nil { 116 log.Printf("[DEBUG] AzureRM Response for %s: \n%s\n", r.URL, dump) 117 } else { 118 // fallback to basic message 119 log.Printf("[DEBUG] AzureRM Response: %s for %s\n", resp.Status, r.URL) 120 } 121 } else { 122 log.Printf("[DEBUG] Request to %s completed with no response", r.URL) 123 } 124 return resp, err 125 }) 126 } 127 } 128 129 func setUserAgent(client *autorest.Client) { 130 version := terraform.VersionString() 131 client.UserAgent = fmt.Sprintf("HashiCorp-Terraform-v%s", version) 132 } 133 134 // getArmClient is a helper method which returns a fully instantiated 135 // *ArmClient based on the Config's current settings. 136 func (c *Config) getArmClient() (*ArmClient, error) { 137 // detect cloud from environment 138 env, envErr := azure.EnvironmentFromName(c.Environment) 139 if envErr != nil { 140 // try again with wrapped value to support readable values like german instead of AZUREGERMANCLOUD 141 wrapped := fmt.Sprintf("AZURE%sCLOUD", c.Environment) 142 var innerErr error 143 if env, innerErr = azure.EnvironmentFromName(wrapped); innerErr != nil { 144 return nil, envErr 145 } 146 } 147 148 // client declarations: 149 client := ArmClient{ 150 clientId: c.ClientID, 151 tenantId: c.TenantID, 152 subscriptionId: c.SubscriptionID, 153 environment: env, 154 } 155 156 rivieraClient, err := riviera.NewClient(&riviera.AzureResourceManagerCredentials{ 157 ClientID: c.ClientID, 158 ClientSecret: c.ClientSecret, 159 TenantID: c.TenantID, 160 SubscriptionID: c.SubscriptionID, 161 ResourceManagerEndpoint: env.ResourceManagerEndpoint, 162 ActiveDirectoryEndpoint: env.ActiveDirectoryEndpoint, 163 }) 164 if err != nil { 165 return nil, fmt.Errorf("Error creating Riviera client: %s", err) 166 } 167 client.rivieraClient = rivieraClient 168 169 oauthConfig, err := env.OAuthConfigForTenant(c.TenantID) 170 if err != nil { 171 return nil, err 172 } 173 174 // OAuthConfigForTenant returns a pointer, which can be nil. 175 if oauthConfig == nil { 176 return nil, fmt.Errorf("Unable to configure OAuthConfig for tenant %s", c.TenantID) 177 } 178 179 spt, err := azure.NewServicePrincipalToken(*oauthConfig, c.ClientID, c.ClientSecret, env.ResourceManagerEndpoint) 180 if err != nil { 181 return nil, err 182 } 183 184 endpoint := env.ResourceManagerEndpoint 185 186 // NOTE: these declarations should be left separate for clarity should the 187 // clients be wished to be configured with custom Responders/PollingModess etc... 188 asc := compute.NewAvailabilitySetsClientWithBaseURI(endpoint, c.SubscriptionID) 189 setUserAgent(&asc.Client) 190 asc.Authorizer = spt 191 asc.Sender = autorest.CreateSender(withRequestLogging()) 192 client.availSetClient = asc 193 194 uoc := compute.NewUsageClientWithBaseURI(endpoint, c.SubscriptionID) 195 setUserAgent(&uoc.Client) 196 uoc.Authorizer = spt 197 uoc.Sender = autorest.CreateSender(withRequestLogging()) 198 client.usageOpsClient = uoc 199 200 vmeic := compute.NewVirtualMachineExtensionImagesClientWithBaseURI(endpoint, c.SubscriptionID) 201 setUserAgent(&vmeic.Client) 202 vmeic.Authorizer = spt 203 vmeic.Sender = autorest.CreateSender(withRequestLogging()) 204 client.vmExtensionImageClient = vmeic 205 206 vmec := compute.NewVirtualMachineExtensionsClientWithBaseURI(endpoint, c.SubscriptionID) 207 setUserAgent(&vmec.Client) 208 vmec.Authorizer = spt 209 vmec.Sender = autorest.CreateSender(withRequestLogging()) 210 client.vmExtensionClient = vmec 211 212 vmic := compute.NewVirtualMachineImagesClientWithBaseURI(endpoint, c.SubscriptionID) 213 setUserAgent(&vmic.Client) 214 vmic.Authorizer = spt 215 vmic.Sender = autorest.CreateSender(withRequestLogging()) 216 client.vmImageClient = vmic 217 218 vmssc := compute.NewVirtualMachineScaleSetsClientWithBaseURI(endpoint, c.SubscriptionID) 219 setUserAgent(&vmssc.Client) 220 vmssc.Authorizer = spt 221 vmssc.Sender = autorest.CreateSender(withRequestLogging()) 222 client.vmScaleSetClient = vmssc 223 224 vmc := compute.NewVirtualMachinesClientWithBaseURI(endpoint, c.SubscriptionID) 225 setUserAgent(&vmc.Client) 226 vmc.Authorizer = spt 227 vmc.Sender = autorest.CreateSender(withRequestLogging()) 228 client.vmClient = vmc 229 230 agc := network.NewApplicationGatewaysClientWithBaseURI(endpoint, c.SubscriptionID) 231 setUserAgent(&agc.Client) 232 agc.Authorizer = spt 233 agc.Sender = autorest.CreateSender(withRequestLogging()) 234 client.appGatewayClient = agc 235 236 crc := containerregistry.NewRegistriesClientWithBaseURI(endpoint, c.SubscriptionID) 237 setUserAgent(&crc.Client) 238 crc.Authorizer = spt 239 crc.Sender = autorest.CreateSender(withRequestLogging()) 240 client.containerRegistryClient = crc 241 242 csc := containerservice.NewContainerServicesClientWithBaseURI(endpoint, c.SubscriptionID) 243 setUserAgent(&csc.Client) 244 csc.Authorizer = spt 245 csc.Sender = autorest.CreateSender(withRequestLogging()) 246 client.containerServicesClient = csc 247 248 ehc := eventhub.NewEventHubsClientWithBaseURI(endpoint, c.SubscriptionID) 249 setUserAgent(&ehc.Client) 250 ehc.Authorizer = spt 251 ehc.Sender = autorest.CreateSender(withRequestLogging()) 252 client.eventHubClient = ehc 253 254 chcgc := eventhub.NewConsumerGroupsClientWithBaseURI(endpoint, c.SubscriptionID) 255 setUserAgent(&chcgc.Client) 256 chcgc.Authorizer = spt 257 chcgc.Sender = autorest.CreateSender(withRequestLogging()) 258 client.eventHubConsumerGroupClient = chcgc 259 260 ehnc := eventhub.NewNamespacesClientWithBaseURI(endpoint, c.SubscriptionID) 261 setUserAgent(&ehnc.Client) 262 ehnc.Authorizer = spt 263 ehnc.Sender = autorest.CreateSender(withRequestLogging()) 264 client.eventHubNamespacesClient = ehnc 265 266 ifc := network.NewInterfacesClientWithBaseURI(endpoint, c.SubscriptionID) 267 setUserAgent(&ifc.Client) 268 ifc.Authorizer = spt 269 ifc.Sender = autorest.CreateSender(withRequestLogging()) 270 client.ifaceClient = ifc 271 272 lbc := network.NewLoadBalancersClientWithBaseURI(endpoint, c.SubscriptionID) 273 setUserAgent(&lbc.Client) 274 lbc.Authorizer = spt 275 lbc.Sender = autorest.CreateSender(withRequestLogging()) 276 client.loadBalancerClient = lbc 277 278 lgc := network.NewLocalNetworkGatewaysClientWithBaseURI(endpoint, c.SubscriptionID) 279 setUserAgent(&lgc.Client) 280 lgc.Authorizer = spt 281 lgc.Sender = autorest.CreateSender(withRequestLogging()) 282 client.localNetConnClient = lgc 283 284 pipc := network.NewPublicIPAddressesClientWithBaseURI(endpoint, c.SubscriptionID) 285 setUserAgent(&pipc.Client) 286 pipc.Authorizer = spt 287 pipc.Sender = autorest.CreateSender(withRequestLogging()) 288 client.publicIPClient = pipc 289 290 sgc := network.NewSecurityGroupsClientWithBaseURI(endpoint, c.SubscriptionID) 291 setUserAgent(&sgc.Client) 292 sgc.Authorizer = spt 293 sgc.Sender = autorest.CreateSender(withRequestLogging()) 294 client.secGroupClient = sgc 295 296 src := network.NewSecurityRulesClientWithBaseURI(endpoint, c.SubscriptionID) 297 setUserAgent(&src.Client) 298 src.Authorizer = spt 299 src.Sender = autorest.CreateSender(withRequestLogging()) 300 client.secRuleClient = src 301 302 snc := network.NewSubnetsClientWithBaseURI(endpoint, c.SubscriptionID) 303 setUserAgent(&snc.Client) 304 snc.Authorizer = spt 305 snc.Sender = autorest.CreateSender(withRequestLogging()) 306 client.subnetClient = snc 307 308 vgcc := network.NewVirtualNetworkGatewayConnectionsClientWithBaseURI(endpoint, c.SubscriptionID) 309 setUserAgent(&vgcc.Client) 310 vgcc.Authorizer = spt 311 vgcc.Sender = autorest.CreateSender(withRequestLogging()) 312 client.vnetGatewayConnectionsClient = vgcc 313 314 vgc := network.NewVirtualNetworkGatewaysClientWithBaseURI(endpoint, c.SubscriptionID) 315 setUserAgent(&vgc.Client) 316 vgc.Authorizer = spt 317 vgc.Sender = autorest.CreateSender(withRequestLogging()) 318 client.vnetGatewayClient = vgc 319 320 vnc := network.NewVirtualNetworksClientWithBaseURI(endpoint, c.SubscriptionID) 321 setUserAgent(&vnc.Client) 322 vnc.Authorizer = spt 323 vnc.Sender = autorest.CreateSender(withRequestLogging()) 324 client.vnetClient = vnc 325 326 vnpc := network.NewVirtualNetworkPeeringsClientWithBaseURI(endpoint, c.SubscriptionID) 327 setUserAgent(&vnpc.Client) 328 vnpc.Authorizer = spt 329 vnpc.Sender = autorest.CreateSender(withRequestLogging()) 330 client.vnetPeeringsClient = vnpc 331 332 rtc := network.NewRouteTablesClientWithBaseURI(endpoint, c.SubscriptionID) 333 setUserAgent(&rtc.Client) 334 rtc.Authorizer = spt 335 rtc.Sender = autorest.CreateSender(withRequestLogging()) 336 client.routeTablesClient = rtc 337 338 rc := network.NewRoutesClientWithBaseURI(endpoint, c.SubscriptionID) 339 setUserAgent(&rc.Client) 340 rc.Authorizer = spt 341 rc.Sender = autorest.CreateSender(withRequestLogging()) 342 client.routesClient = rc 343 344 rgc := resources.NewGroupsClientWithBaseURI(endpoint, c.SubscriptionID) 345 setUserAgent(&rgc.Client) 346 rgc.Authorizer = spt 347 rgc.Sender = autorest.CreateSender(withRequestLogging()) 348 client.resourceGroupClient = rgc 349 350 pc := resources.NewProvidersClientWithBaseURI(endpoint, c.SubscriptionID) 351 setUserAgent(&pc.Client) 352 pc.Authorizer = spt 353 pc.Sender = autorest.CreateSender(withRequestLogging()) 354 client.providers = pc 355 356 tc := resources.NewTagsClientWithBaseURI(endpoint, c.SubscriptionID) 357 setUserAgent(&tc.Client) 358 tc.Authorizer = spt 359 tc.Sender = autorest.CreateSender(withRequestLogging()) 360 client.tagsClient = tc 361 362 rf := resources.NewGroupClientWithBaseURI(endpoint, c.SubscriptionID) 363 setUserAgent(&rf.Client) 364 rf.Authorizer = spt 365 rf.Sender = autorest.CreateSender(withRequestLogging()) 366 client.resourceFindClient = rf 367 368 jc := scheduler.NewJobsClientWithBaseURI(endpoint, c.SubscriptionID) 369 setUserAgent(&jc.Client) 370 jc.Authorizer = spt 371 jc.Sender = autorest.CreateSender(withRequestLogging()) 372 client.jobsClient = jc 373 374 jcc := scheduler.NewJobCollectionsClientWithBaseURI(endpoint, c.SubscriptionID) 375 setUserAgent(&jcc.Client) 376 jcc.Authorizer = spt 377 jcc.Sender = autorest.CreateSender(withRequestLogging()) 378 client.jobsCollectionsClient = jcc 379 380 ssc := storage.NewAccountsClientWithBaseURI(endpoint, c.SubscriptionID) 381 setUserAgent(&ssc.Client) 382 ssc.Authorizer = spt 383 ssc.Sender = autorest.CreateSender(withRequestLogging()) 384 client.storageServiceClient = ssc 385 386 suc := storage.NewUsageOperationsClientWithBaseURI(endpoint, c.SubscriptionID) 387 setUserAgent(&suc.Client) 388 suc.Authorizer = spt 389 suc.Sender = autorest.CreateSender(withRequestLogging()) 390 client.storageUsageClient = suc 391 392 cpc := cdn.NewProfilesClientWithBaseURI(endpoint, c.SubscriptionID) 393 setUserAgent(&cpc.Client) 394 cpc.Authorizer = spt 395 cpc.Sender = autorest.CreateSender(withRequestLogging()) 396 client.cdnProfilesClient = cpc 397 398 cec := cdn.NewEndpointsClientWithBaseURI(endpoint, c.SubscriptionID) 399 setUserAgent(&cec.Client) 400 cec.Authorizer = spt 401 cec.Sender = autorest.CreateSender(withRequestLogging()) 402 client.cdnEndpointsClient = cec 403 404 dc := resources.NewDeploymentsClientWithBaseURI(endpoint, c.SubscriptionID) 405 setUserAgent(&dc.Client) 406 dc.Authorizer = spt 407 dc.Sender = autorest.CreateSender(withRequestLogging()) 408 client.deploymentsClient = dc 409 410 tmpc := trafficmanager.NewProfilesClientWithBaseURI(endpoint, c.SubscriptionID) 411 setUserAgent(&tmpc.Client) 412 tmpc.Authorizer = spt 413 tmpc.Sender = autorest.CreateSender(withRequestLogging()) 414 client.trafficManagerProfilesClient = tmpc 415 416 tmec := trafficmanager.NewEndpointsClientWithBaseURI(endpoint, c.SubscriptionID) 417 setUserAgent(&tmec.Client) 418 tmec.Authorizer = spt 419 tmec.Sender = autorest.CreateSender(withRequestLogging()) 420 client.trafficManagerEndpointsClient = tmec 421 422 rdc := redis.NewGroupClientWithBaseURI(endpoint, c.SubscriptionID) 423 setUserAgent(&rdc.Client) 424 rdc.Authorizer = spt 425 rdc.Sender = autorest.CreateSender(withRequestLogging()) 426 client.redisClient = rdc 427 428 sbnc := servicebus.NewNamespacesClientWithBaseURI(endpoint, c.SubscriptionID) 429 setUserAgent(&sbnc.Client) 430 sbnc.Authorizer = spt 431 sbnc.Sender = autorest.CreateSender(withRequestLogging()) 432 client.serviceBusNamespacesClient = sbnc 433 434 sbtc := servicebus.NewTopicsClientWithBaseURI(endpoint, c.SubscriptionID) 435 setUserAgent(&sbtc.Client) 436 sbtc.Authorizer = spt 437 sbtc.Sender = autorest.CreateSender(withRequestLogging()) 438 client.serviceBusTopicsClient = sbtc 439 440 sbsc := servicebus.NewSubscriptionsClientWithBaseURI(endpoint, c.SubscriptionID) 441 setUserAgent(&sbsc.Client) 442 sbsc.Authorizer = spt 443 sbsc.Sender = autorest.CreateSender(withRequestLogging()) 444 client.serviceBusSubscriptionsClient = sbsc 445 446 kvc := keyvault.NewVaultsClientWithBaseURI(endpoint, c.SubscriptionID) 447 setUserAgent(&kvc.Client) 448 kvc.Authorizer = spt 449 kvc.Sender = autorest.CreateSender(withRequestLogging()) 450 client.keyVaultClient = kvc 451 452 return &client, nil 453 } 454 455 func (armClient *ArmClient) getKeyForStorageAccount(resourceGroupName, storageAccountName string) (string, bool, error) { 456 accountKeys, err := armClient.storageServiceClient.ListKeys(resourceGroupName, storageAccountName) 457 if accountKeys.StatusCode == http.StatusNotFound { 458 return "", false, nil 459 } 460 if err != nil { 461 // We assume this is a transient error rather than a 404 (which is caught above), so assume the 462 // account still exists. 463 return "", true, fmt.Errorf("Error retrieving keys for storage account %q: %s", storageAccountName, err) 464 } 465 466 if accountKeys.Keys == nil { 467 return "", false, fmt.Errorf("Nil key returned for storage account %q", storageAccountName) 468 } 469 470 keys := *accountKeys.Keys 471 return *keys[0].Value, true, nil 472 } 473 474 func (armClient *ArmClient) getBlobStorageClientForStorageAccount(resourceGroupName, storageAccountName string) (*mainStorage.BlobStorageClient, bool, error) { 475 key, accountExists, err := armClient.getKeyForStorageAccount(resourceGroupName, storageAccountName) 476 if err != nil { 477 return nil, accountExists, err 478 } 479 if accountExists == false { 480 return nil, false, nil 481 } 482 483 storageClient, err := mainStorage.NewClient(storageAccountName, key, armClient.environment.StorageEndpointSuffix, 484 mainStorage.DefaultAPIVersion, true) 485 if err != nil { 486 return nil, true, fmt.Errorf("Error creating storage client for storage account %q: %s", storageAccountName, err) 487 } 488 489 blobClient := storageClient.GetBlobService() 490 return &blobClient, true, nil 491 } 492 493 func (armClient *ArmClient) getFileServiceClientForStorageAccount(resourceGroupName, storageAccountName string) (*mainStorage.FileServiceClient, bool, error) { 494 key, accountExists, err := armClient.getKeyForStorageAccount(resourceGroupName, storageAccountName) 495 if err != nil { 496 return nil, accountExists, err 497 } 498 if accountExists == false { 499 return nil, false, nil 500 } 501 502 storageClient, err := mainStorage.NewClient(storageAccountName, key, armClient.environment.StorageEndpointSuffix, 503 mainStorage.DefaultAPIVersion, true) 504 if err != nil { 505 return nil, true, fmt.Errorf("Error creating storage client for storage account %q: %s", storageAccountName, err) 506 } 507 508 fileClient := storageClient.GetFileService() 509 return &fileClient, true, nil 510 } 511 512 func (armClient *ArmClient) getTableServiceClientForStorageAccount(resourceGroupName, storageAccountName string) (*mainStorage.TableServiceClient, bool, error) { 513 key, accountExists, err := armClient.getKeyForStorageAccount(resourceGroupName, storageAccountName) 514 if err != nil { 515 return nil, accountExists, err 516 } 517 if accountExists == false { 518 return nil, false, nil 519 } 520 521 storageClient, err := mainStorage.NewClient(storageAccountName, key, armClient.environment.StorageEndpointSuffix, 522 mainStorage.DefaultAPIVersion, true) 523 if err != nil { 524 return nil, true, fmt.Errorf("Error creating storage client for storage account %q: %s", storageAccountName, err) 525 } 526 527 tableClient := storageClient.GetTableService() 528 return &tableClient, true, nil 529 } 530 531 func (armClient *ArmClient) getQueueServiceClientForStorageAccount(resourceGroupName, storageAccountName string) (*mainStorage.QueueServiceClient, bool, error) { 532 key, accountExists, err := armClient.getKeyForStorageAccount(resourceGroupName, storageAccountName) 533 if err != nil { 534 return nil, accountExists, err 535 } 536 if accountExists == false { 537 return nil, false, nil 538 } 539 540 storageClient, err := mainStorage.NewClient(storageAccountName, key, armClient.environment.StorageEndpointSuffix, 541 mainStorage.DefaultAPIVersion, true) 542 if err != nil { 543 return nil, true, fmt.Errorf("Error creating storage client for storage account %q: %s", storageAccountName, err) 544 } 545 546 queueClient := storageClient.GetQueueService() 547 return &queueClient, true, nil 548 }