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 - Stop silently consuming 404 error when reading storage service properties #19062

Merged
merged 1 commit into from
Jan 17, 2023
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
13 changes: 4 additions & 9 deletions internal/services/storage/storage_account_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -2039,9 +2039,7 @@ func resourceStorageAccountRead(d *pluginsdk.ResourceData, meta interface{}) err
blobClient := storageClient.BlobServicesClient
blobProps, err := blobClient.GetServiceProperties(ctx, id.ResourceGroup, id.Name)
if err != nil {
if !utils.ResponseWasNotFound(blobProps.Response) {
return fmt.Errorf("reading blob properties for AzureRM Storage Account %q: %+v", id.Name, err)
}
return fmt.Errorf("reading blob properties for AzureRM Storage Account %q: %+v", id.Name, err)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

from memory this API can only be called for some kind of Storage Accounts, otherwise it returns a 404 - so I think this'll break those (I want to say Blob/File accounts?)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then we shall accordingly update the code that evaluates the supportLevel?

func resolveStorageAccountServiceSupportLevel(kind storage.Kind, tier storage.SkuTier) storageAccountServiceSupportLevel {

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure, there should be tests for that - would you be able to take a look?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tombuildsstuff Yes, I've tried to deploy storage accounts of all the five possible account_kind, which are all successfully created and have no diff in a follow-up plan. I've checked that these possible account_kind are also covered in the existing acctests.

}
if err := d.Set("blob_properties", flattenBlobProperties(blobProps)); err != nil {
return fmt.Errorf("setting `blob_properties `for AzureRM Storage Account %q: %+v", id.Name, err)
Expand All @@ -2066,11 +2064,10 @@ func resourceStorageAccountRead(d *pluginsdk.ResourceData, meta interface{}) err

if supportLevel.supportShare {
fileServiceClient := storageClient.FileServicesClient

shareProps, err := fileServiceClient.GetServiceProperties(ctx, id.ResourceGroup, id.Name)
if err != nil {
if !utils.ResponseWasNotFound(shareProps.Response) {
return fmt.Errorf("reading share properties for AzureRM Storage Account %q: %+v", id.Name, err)
}
return fmt.Errorf("reading share properties for AzureRM Storage Account %q: %+v", id.Name, err)
}

if err := d.Set("share_properties", flattenShareProperties(shareProps)); err != nil {
Expand All @@ -2092,9 +2089,7 @@ func resourceStorageAccountRead(d *pluginsdk.ResourceData, meta interface{}) err

staticWebsiteProps, err := accountsClient.GetServiceProperties(ctx, id.Name)
if err != nil {
if staticWebsiteProps.Response.Response != nil && !utils.ResponseWasNotFound(staticWebsiteProps.Response) {
return fmt.Errorf("reading static website for AzureRM Storage Account %q: %+v", id.Name, err)
}
return fmt.Errorf("reading static website for AzureRM Storage Account %q: %+v", id.Name, err)
}
staticWebsite := flattenStaticWebsiteProperties(staticWebsiteProps)
if err := d.Set("static_website", staticWebsite); err != nil {
Expand Down