Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
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
Solved! Go to Solution.
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.
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?
This is not the solution we are looking for.
What we are looking for is? How to connect PowerBI workspace to Log Analytics Workspace?
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.
The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!
Check out the November 2025 Power BI update to learn about new features.