diff --git a/internal/services/machinelearning/machine_learning_datastore_blobstorage_resource.go b/internal/services/machinelearning/machine_learning_datastore_blobstorage_resource.go index 9dd8f17c3f44..e64c2729071f 100644 --- a/internal/services/machinelearning/machine_learning_datastore_blobstorage_resource.go +++ b/internal/services/machinelearning/machine_learning_datastore_blobstorage_resource.go @@ -282,6 +282,7 @@ func (r MachineLearningDataStoreBlobStorage) Read() sdk.ResourceFunc { Timeout: 5 * time.Minute, Func: func(ctx context.Context, metadata sdk.ResourceMetaData) error { client := metadata.Client.MachineLearning.Datastore + storageClient := metadata.Client.Storage subscriptionId := metadata.Client.Account.SubscriptionId id, err := datastore.ParseDataStoreID(metadata.ResourceData.Id()) @@ -310,8 +311,16 @@ func (r MachineLearningDataStoreBlobStorage) Read() sdk.ResourceFunc { } model.ServiceDataAuthIdentity = serviceDataAuth - containerId := commonids.NewStorageContainerID(subscriptionId, workspaceId.ResourceGroupName, *data.AccountName, *data.ContainerName) + storageAccount, err := storageClient.FindAccount(ctx, *data.AccountName) + if err != nil { + return fmt.Errorf("retrieving Account %q for Container %q: %s", *data.AccountName, *data.ContainerName, err) + } + if storageAccount == nil { + return fmt.Errorf("Unable to locate Storage Account %q!", *data.AccountName) + } + containerId := commonids.NewStorageContainerID(subscriptionId, storageAccount.ResourceGroup, *data.AccountName, *data.ContainerName) model.StorageContainerID = containerId.ID() + model.IsDefault = *data.IsDefault if v, ok := metadata.ResourceData.GetOk("account_key"); ok { diff --git a/internal/services/machinelearning/machine_learning_datastore_datalake_gen2_resource.go b/internal/services/machinelearning/machine_learning_datastore_datalake_gen2_resource.go index 365a7db046e3..eceb7ed3a240 100644 --- a/internal/services/machinelearning/machine_learning_datastore_datalake_gen2_resource.go +++ b/internal/services/machinelearning/machine_learning_datastore_datalake_gen2_resource.go @@ -282,6 +282,7 @@ func (r MachineLearningDataStoreDataLakeGen2) Read() sdk.ResourceFunc { Timeout: 5 * time.Minute, Func: func(ctx context.Context, metadata sdk.ResourceMetaData) error { client := metadata.Client.MachineLearning.Datastore + storageClient := metadata.Client.Storage subscriptionId := metadata.Client.Account.SubscriptionId id, err := datastore.ParseDataStoreID(metadata.ResourceData.Id()) @@ -310,7 +311,14 @@ func (r MachineLearningDataStoreDataLakeGen2) Read() sdk.ResourceFunc { } model.ServiceDataIdentity = serviceDataIdentity - containerId := commonids.NewStorageContainerID(subscriptionId, workspaceId.ResourceGroupName, data.AccountName, data.Filesystem) + storageAccount, err := storageClient.FindAccount(ctx, data.AccountName) + if err != nil { + return fmt.Errorf("retrieving Account %q for Data Lake Gen2 File System %q: %s", data.AccountName, data.Filesystem, err) + } + if storageAccount == nil { + return fmt.Errorf("Unable to locate Storage Account %q!", data.AccountName) + } + containerId := commonids.NewStorageContainerID(subscriptionId, storageAccount.ResourceGroup, data.AccountName, data.Filesystem) model.StorageContainerID = containerId.ID() model.IsDefault = *data.IsDefault diff --git a/internal/services/machinelearning/machine_learning_datastore_fileshare_resource.go b/internal/services/machinelearning/machine_learning_datastore_fileshare_resource.go index 0dd3edd78058..f646f0b65b12 100644 --- a/internal/services/machinelearning/machine_learning_datastore_fileshare_resource.go +++ b/internal/services/machinelearning/machine_learning_datastore_fileshare_resource.go @@ -273,6 +273,7 @@ func (r MachineLearningDataStoreFileShare) Read() sdk.ResourceFunc { Timeout: 5 * time.Minute, Func: func(ctx context.Context, metadata sdk.ResourceMetaData) error { client := metadata.Client.MachineLearning.Datastore + storageClient := metadata.Client.Storage subscriptionId := metadata.Client.Account.SubscriptionId id, err := datastore.ParseDataStoreID(metadata.ResourceData.Id()) @@ -301,8 +302,16 @@ func (r MachineLearningDataStoreFileShare) Read() sdk.ResourceFunc { } model.ServiceDataIdentity = serviceDataIdentity - fileShareId := storageparse.NewStorageShareResourceManagerID(subscriptionId, workspaceId.ResourceGroupName, data.AccountName, "default", data.FileShareName) + storageAccount, err := storageClient.FindAccount(ctx, data.AccountName) + if err != nil { + return fmt.Errorf("retrieving Account %q for Share %q: %s", data.AccountName, data.FileShareName, err) + } + if storageAccount == nil { + return fmt.Errorf("Unable to locate Storage Account %q!", data.AccountName) + } + fileShareId := storageparse.NewStorageShareResourceManagerID(subscriptionId, storageAccount.ResourceGroup, data.AccountName, "default", data.FileShareName) model.StorageFileShareID = fileShareId.ID() + model.IsDefault = *data.IsDefault if v, ok := metadata.ResourceData.GetOk("account_key"); ok {