diff --git a/internal/services/storage/storage_container_data_source.go b/internal/services/storage/storage_container_data_source.go index 30e99688f495..7e37aad6bbb3 100644 --- a/internal/services/storage/storage_container_data_source.go +++ b/internal/services/storage/storage_container_data_source.go @@ -117,7 +117,11 @@ func dataSourceStorageContainerRead(d *pluginsdk.ResourceData, meta interface{}) d.Set("has_immutability_policy", props.HasImmutabilityPolicy) d.Set("has_legal_hold", props.HasLegalHold) - resourceManagerId := commonids.NewStorageContainerID(storageClient.SubscriptionId, account.ResourceGroup, accountName, containerName) + storageAccountId, err := commonids.ParseStorageAccountIDInsensitively(account.ID) + if err != nil { + return err + } + resourceManagerId := commonids.NewStorageContainerID(storageAccountId.SubscriptionId, storageAccountId.ResourceGroupName, storageAccountId.StorageAccountName, containerName) d.Set("resource_manager_id", resourceManagerId.ID()) return nil diff --git a/internal/services/storage/storage_share_data_source.go b/internal/services/storage/storage_share_data_source.go index 9faace9ed9ae..6975dd5d1fad 100644 --- a/internal/services/storage/storage_share_data_source.go +++ b/internal/services/storage/storage_share_data_source.go @@ -5,6 +5,7 @@ package storage import ( "fmt" + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" "time" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" @@ -139,7 +140,11 @@ func dataSourceStorageShareRead(d *pluginsdk.ResourceData, meta interface{}) err return fmt.Errorf("setting `metadata`: %v", err) } - resourceManagerId := parse.NewStorageShareResourceManagerID(storageClient.SubscriptionId, account.ResourceGroup, accountName, "default", shareName) + storageAccountId, err := commonids.ParseStorageAccountIDInsensitively(account.ID) + if err != nil { + return err + } + resourceManagerId := parse.NewStorageShareResourceManagerID(storageAccountId.SubscriptionId, storageAccountId.ResourceGroupName, storageAccountId.StorageAccountName, "default", shareName) d.Set("resource_manager_id", resourceManagerId.ID()) return nil diff --git a/internal/services/storage/storage_share_resource.go b/internal/services/storage/storage_share_resource.go index 58b923dec4da..1f8350f4c2b7 100644 --- a/internal/services/storage/storage_share_resource.go +++ b/internal/services/storage/storage_share_resource.go @@ -5,6 +5,7 @@ package storage import ( "fmt" + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" "log" "time" @@ -285,7 +286,11 @@ func resourceStorageShareRead(d *pluginsdk.ResourceData, meta interface{}) error return fmt.Errorf("flattening `metadata`: %+v", err) } - resourceManagerId := parse.NewStorageShareResourceManagerID(storageClient.SubscriptionId, account.ResourceGroup, id.AccountId.AccountName, "default", id.ShareName) + storageAccountId, err := commonids.ParseStorageAccountIDInsensitively(account.ID) + if err != nil { + return err + } + resourceManagerId := parse.NewStorageShareResourceManagerID(storageAccountId.SubscriptionId, storageAccountId.ResourceGroupName, storageAccountId.StorageAccountName, "default", id.ShareName) d.Set("resource_manager_id", resourceManagerId.ID()) return nil