Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

azurerm_storage_account - fix performance issue for accounts that don't support queues #5316

Merged
merged 4 commits into from
Jan 8, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 20 additions & 11 deletions azurerm/internal/services/storage/resource_arm_storage_account.go
Original file line number Diff line number Diff line change
Expand Up @@ -1239,20 +1239,29 @@ func resourceArmStorageAccountRead(d *schema.ResourceData, meta interface{}) err
}
}

queueClient, err := storageClient.QueuesClient(ctx, *account)
if err != nil {
return fmt.Errorf("Error building Queues Client: %s", err)
// queue is only available for certain tier and kind (as specified below)
if resp.Sku == nil {
return fmt.Errorf("Error retrieving Storage Account %q (Resource Group %q): `sku` was nil", name, resGroup)
}

queueProps, err := queueClient.GetServiceProperties(ctx, name)
if err != nil {
if queueProps.Response.Response != nil && !utils.ResponseWasNotFound(queueProps.Response) {
return fmt.Errorf("Error reading queue properties for AzureRM Storage Account %q: %+v", name, err)
}
}
if resp.Sku.Tier == storage.Standard {
magodo marked this conversation as resolved.
Show resolved Hide resolved
if resp.Kind == storage.Storage || resp.Kind == storage.StorageV2 {
queueClient, err := storageClient.QueuesClient(ctx, *account)
if err != nil {
return fmt.Errorf("Error building Queues Client: %s", err)
}

if err := d.Set("queue_properties", flattenQueueProperties(queueProps)); err != nil {
return fmt.Errorf("Error setting `queue_properties `for AzureRM Storage Account %q: %+v", name, err)
queueProps, err := queueClient.GetServiceProperties(ctx, name)
if err != nil {
if queueProps.Response.Response != nil && !utils.ResponseWasNotFound(queueProps.Response) {
return fmt.Errorf("Error reading queue properties for AzureRM Storage Account %q: %+v", name, err)
}
}

if err := d.Set("queue_properties", flattenQueueProperties(queueProps)); err != nil {
return fmt.Errorf("Error setting `queue_properties `for AzureRM Storage Account %q: %+v", name, err)
}
}
}

return tags.FlattenAndSet(d, resp.Tags)
Expand Down