Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix wrong container ID and file share IDs for all Azure ML Data stores #23140

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down Expand Up @@ -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 {
Expand Down