Skip to content

Commit

Permalink
fix(log_analytics_storage_insights): Parse subscriptionId from worksp…
Browse files Browse the repository at this point in the history
…aceId

Subscription ID where to create `log_analytics_storage_insights` should
be the same as the Log Analytics Workspace.

When passing a `workspaceId` with a different Azure subscription than
the current one, resource group could not be found:

 Error: creating/updating Storage Insight Config (Subscription: "13-xxxx-aa"
 Resource Group Name: "rg-dev-test"
 Workspace Name: "logaws-dev-test"
 Storage Insight Config Name: "logsi-stdevstoragestoragsjkbl4"): unexpected
  status 404 (404 Not Found) with error: ResourceGroupNotFound:
 Resource group 'rg-dev-test' could not be found.

Fixes #28466
  • Loading branch information
xescab committed Jan 17, 2025
1 parent ce9d7aa commit 4fb1ae9
Showing 1 changed file with 1 addition and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ func resourceLogAnalyticsStorageInsights() *pluginsdk.Resource {

func resourceLogAnalyticsStorageInsightsCreateUpdate(d *pluginsdk.ResourceData, meta interface{}) error {
client := meta.(*clients.Client).LogAnalytics.StorageInsightsClient
subscriptionId := meta.(*clients.Client).Account.SubscriptionId
ctx, cancel := timeouts.ForCreateUpdate(meta.(*clients.Client).StopContext, d)
defer cancel()

Expand All @@ -67,7 +66,7 @@ func resourceLogAnalyticsStorageInsightsCreateUpdate(d *pluginsdk.ResourceData,
if err != nil {
return err
}
id := storageinsights.NewStorageInsightConfigID(subscriptionId, resourceGroup, workspace.WorkspaceName, name)
id := storageinsights.NewStorageInsightConfigID(workspace.SubscriptionId, resourceGroup, workspace.WorkspaceName, name)

if d.IsNewResource() {
existing, err := client.StorageInsightConfigsGet(ctx, id)
Expand Down

0 comments on commit 4fb1ae9

Please sign in to comment.