From f60fd2b0a3395b82ef314d9d3b6d571061eb6db0 Mon Sep 17 00:00:00 2001 From: bloewes <117997874+bloewes@users.noreply.github.com> Date: Thu, 31 Aug 2023 11:43:20 +0200 Subject: [PATCH 1/4] Update machine_learning_datastore_datalake_gen2_resource.go --- .../machine_learning_datastore_datalake_gen2_resource.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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..677e6801bad3 100644 --- a/internal/services/machinelearning/machine_learning_datastore_datalake_gen2_resource.go +++ b/internal/services/machinelearning/machine_learning_datastore_datalake_gen2_resource.go @@ -310,7 +310,7 @@ func (r MachineLearningDataStoreDataLakeGen2) Read() sdk.ResourceFunc { } model.ServiceDataIdentity = serviceDataIdentity - containerId := commonids.NewStorageContainerID(subscriptionId, workspaceId.ResourceGroupName, data.AccountName, data.Filesystem) + containerId := commonids.NewStorageContainerID(subscriptionId, data.ResourceGroupName, data.AccountName, data.Filesystem) model.StorageContainerID = containerId.ID() model.IsDefault = *data.IsDefault From 26b6e762a8f8018c3559505b65e3d82e71ad6f95 Mon Sep 17 00:00:00 2001 From: bloewes <117997874+bloewes@users.noreply.github.com> Date: Thu, 31 Aug 2023 11:43:57 +0200 Subject: [PATCH 2/4] Update machine_learning_datastore_blobstorage_resource.go --- .../machine_learning_datastore_blobstorage_resource.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/services/machinelearning/machine_learning_datastore_blobstorage_resource.go b/internal/services/machinelearning/machine_learning_datastore_blobstorage_resource.go index 9dd8f17c3f44..2092081231b0 100644 --- a/internal/services/machinelearning/machine_learning_datastore_blobstorage_resource.go +++ b/internal/services/machinelearning/machine_learning_datastore_blobstorage_resource.go @@ -310,7 +310,7 @@ func (r MachineLearningDataStoreBlobStorage) Read() sdk.ResourceFunc { } model.ServiceDataAuthIdentity = serviceDataAuth - containerId := commonids.NewStorageContainerID(subscriptionId, workspaceId.ResourceGroupName, *data.AccountName, *data.ContainerName) + containerId := commonids.NewStorageContainerID(subscriptionId, *data.ResourceGroupName, *data.AccountName, *data.ContainerName) model.StorageContainerID = containerId.ID() model.IsDefault = *data.IsDefault From d5d509d4a81df319a4f995c803c524b197fce12b Mon Sep 17 00:00:00 2001 From: bloewes <117997874+bloewes@users.noreply.github.com> Date: Thu, 31 Aug 2023 11:45:07 +0200 Subject: [PATCH 3/4] Update machine_learning_datastore_fileshare_resource.go --- .../machine_learning_datastore_fileshare_resource.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/services/machinelearning/machine_learning_datastore_fileshare_resource.go b/internal/services/machinelearning/machine_learning_datastore_fileshare_resource.go index 0dd3edd78058..e6909fafd76b 100644 --- a/internal/services/machinelearning/machine_learning_datastore_fileshare_resource.go +++ b/internal/services/machinelearning/machine_learning_datastore_fileshare_resource.go @@ -301,7 +301,7 @@ func (r MachineLearningDataStoreFileShare) Read() sdk.ResourceFunc { } model.ServiceDataIdentity = serviceDataIdentity - fileShareId := storageparse.NewStorageShareResourceManagerID(subscriptionId, workspaceId.ResourceGroupName, data.AccountName, "default", data.FileShareName) + fileShareId := storageparse.NewStorageShareResourceManagerID(subscriptionId, data.ResourceGroupName, data.AccountName, "default", data.FileShareName) model.StorageFileShareID = fileShareId.ID() model.IsDefault = *data.IsDefault From 336eb2c55942512323975bf619368ff4ed73dd8a Mon Sep 17 00:00:00 2001 From: bloewes Date: Thu, 31 Aug 2023 20:23:25 +0200 Subject: [PATCH 4/4] fix --- ...machine_learning_datastore_blobstorage_resource.go | 11 ++++++++++- ...chine_learning_datastore_datalake_gen2_resource.go | 10 +++++++++- .../machine_learning_datastore_fileshare_resource.go | 11 ++++++++++- 3 files changed, 29 insertions(+), 3 deletions(-) diff --git a/internal/services/machinelearning/machine_learning_datastore_blobstorage_resource.go b/internal/services/machinelearning/machine_learning_datastore_blobstorage_resource.go index 2092081231b0..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, *data.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 677e6801bad3..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, data.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 e6909fafd76b..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, data.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 {