From f3dc2c6b355858152ea4cfd52a61cb5b5ac3b4fe Mon Sep 17 00:00:00 2001 From: Tom Bamford Date: Mon, 18 Mar 2024 22:06:37 +0000 Subject: [PATCH] bugfix: fix a bug parsing the table endpoint into a data plane account ID in data.azurerm_storage_table_entity --- .../storage/storage_table_entity_data_source.go | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/internal/services/storage/storage_table_entity_data_source.go b/internal/services/storage/storage_table_entity_data_source.go index 75ca7869a1233..d2f31f3ec1f9f 100644 --- a/internal/services/storage/storage_table_entity_data_source.go +++ b/internal/services/storage/storage_table_entity_data_source.go @@ -5,6 +5,7 @@ package storage import ( "fmt" + "github.com/hashicorp/terraform-provider-azurerm/internal/services/storage/client" "time" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" @@ -78,12 +79,17 @@ func dataSourceStorageTableEntityRead(d *pluginsdk.ResourceData, meta interface{ return fmt.Errorf("the parent Storage Account %s was not found", accountName) } - client, err := storageClient.TableEntityDataPlaneClient(ctx, *account, storageClient.DataPlaneOperationSupportingAnyAuthMethod()) + dataPlaneClient, err := storageClient.TableEntityDataPlaneClient(ctx, *account, storageClient.DataPlaneOperationSupportingAnyAuthMethod()) if err != nil { return fmt.Errorf("building Table Entity Client for Storage Account %q (Resource Group %q): %v", accountName, account.ResourceGroup, err) } - accountId, err := accounts.ParseAccountID(accountName, storageClient.StorageDomainSuffix) + endpoint, err := account.DataPlaneEndpoint(client.EndpointTypeTable) + if err != nil { + return fmt.Errorf("retrieving the table data plan endpoint: %v", err) + } + + accountId, err := accounts.ParseAccountID(*endpoint, storageClient.StorageDomainSuffix) if err != nil { return fmt.Errorf("parsing Account ID: %v", err) } @@ -96,7 +102,7 @@ func dataSourceStorageTableEntityRead(d *pluginsdk.ResourceData, meta interface{ MetaDataLevel: entities.NoMetaData, } - result, err := client.Get(ctx, tableName, input) + result, err := dataPlaneClient.Get(ctx, tableName, input) if err != nil { return fmt.Errorf("retrieving %s: %v", id, err) }