Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
lelalaoui
Frequent Visitor

Power BI premium | connect workspaces to an Azure log analytics

Dear community,

I have a P1 node where I'm hosting hunders if workspaces and I need to connect them all to an Azure log analytics.

The feature is now enabled and restricted to the right security group but now I need to mass attach all my workspaces to the log analytics, so I'm reaching you to help with a way to apply this in bulk either from the portal or via Powershell.

Thanks for the great help.

Kind regards

Hassan

1 ACCEPTED SOLUTION
v-henryk-mstf
Community Support
Community Support

Hi @lelalaoui ,

 

To attach multiple workspaces to an Azure Log Analytics workspace in bulk, you can use PowerShell and the Azure Log Analytics REST API.

Here is an outline of the steps you can follow:

First, you need to authenticate to Azure using the Azure PowerShell module. You can do this by running the following command:

Connect-AzAccount


Next, you'll need to get the resource ID of the Log Analytics workspace that you want to attach the workspaces to. You can do this by running the following command:

Get-AzResource -ResourceType "Microsoft.OperationalInsights/workspaces"


Copy the resource ID of the Log Analytics workspace and save it to a variable. You can do this by running the following command:

$logAnalyticsWorkspaceId = "<resource-id>"


Next, you'll need to get the list of workspaces that you want to attach to the Log Analytics workspace. You can do this by running the following command:

$workspaces = Get-AzResource -ResourceType "Microsoft.OperationalInsights/workspaces"


Next, you'll need to create a JSON payload that contains the resource ID of the Log Analytics workspace and the list of workspaces that you want to attach. The payload should look like this:

{
"properties": {
"sourceResourceIds": [
"<workspace-1-resource-id>",
"<workspace-2-resource-id>",
...
]
}
}


Use the Azure REST API to attach the workspaces to the Log Analytics workspace. You can do this by running the following command:

Invoke-RestMethod -Method PUT -Uri "https://management.azure.com/$logAnalyticsWorkspaceId/providers/Microsoft.OperationalInsights/workspacesAttach?api-version=2015-11-01-preview" -Body $payload -ContentType "application/json"


This should attach all of the workspaces to the Log Analytics workspace in bulk.


If the problem is still not resolved, please provide detailed error information and let me know immediately. Looking forward to your reply.


Best Regards,
Henry


If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
KarthikT
New Member

Hi @v-henryk-mstf , 

 

This is not the solution we are looking for.

What we are looking for is? How to connect PowerBI workspace to Log Analytics Workspace using PowerShell or REST API?

KarthikT_0-1709817786925.png

 

KarthikT
New Member

This is not the solution we are looking for.

What we are looking for is? How to connect PowerBI workspace to Log Analytics Workspace?

v-henryk-mstf
Community Support
Community Support

Hi @lelalaoui ,

 

To attach multiple workspaces to an Azure Log Analytics workspace in bulk, you can use PowerShell and the Azure Log Analytics REST API.

Here is an outline of the steps you can follow:

First, you need to authenticate to Azure using the Azure PowerShell module. You can do this by running the following command:

Connect-AzAccount


Next, you'll need to get the resource ID of the Log Analytics workspace that you want to attach the workspaces to. You can do this by running the following command:

Get-AzResource -ResourceType "Microsoft.OperationalInsights/workspaces"


Copy the resource ID of the Log Analytics workspace and save it to a variable. You can do this by running the following command:

$logAnalyticsWorkspaceId = "<resource-id>"


Next, you'll need to get the list of workspaces that you want to attach to the Log Analytics workspace. You can do this by running the following command:

$workspaces = Get-AzResource -ResourceType "Microsoft.OperationalInsights/workspaces"


Next, you'll need to create a JSON payload that contains the resource ID of the Log Analytics workspace and the list of workspaces that you want to attach. The payload should look like this:

{
"properties": {
"sourceResourceIds": [
"<workspace-1-resource-id>",
"<workspace-2-resource-id>",
...
]
}
}


Use the Azure REST API to attach the workspaces to the Log Analytics workspace. You can do this by running the following command:

Invoke-RestMethod -Method PUT -Uri "https://management.azure.com/$logAnalyticsWorkspaceId/providers/Microsoft.OperationalInsights/workspacesAttach?api-version=2015-11-01-preview" -Body $payload -ContentType "application/json"


This should attach all of the workspaces to the Log Analytics workspace in bulk.


If the problem is still not resolved, please provide detailed error information and let me know immediately. Looking forward to your reply.


Best Regards,
Henry


If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.