From 7470f9e2ac8a91660c1b1249dd65cee814193ac2 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 75ca7869a123..036b3f5d2971 100644 --- a/internal/services/storage/storage_table_entity_data_source.go +++ b/internal/services/storage/storage_table_entity_data_source.go @@ -8,6 +8,7 @@ import ( "time" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" + "github.com/hashicorp/terraform-provider-azurerm/internal/services/storage/client" "github.com/hashicorp/terraform-provider-azurerm/internal/services/storage/validate" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/validation" @@ -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) }