Skip to content

Commit

Permalink
bugfix: fix a bug parsing the table endpoint into a data plane accoun…
Browse files Browse the repository at this point in the history
…t ID in data.azurerm_storage_table_entity
  • Loading branch information
manicminer committed Mar 18, 2024
1 parent 91352c2 commit 7470f9e
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions internal/services/storage/storage_table_entity_data_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
}
Expand All @@ -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)
}
Expand Down

0 comments on commit 7470f9e

Please sign in to comment.