How can I automate connecting new subscriptions to a central Log Analytics Workspace?

Copper Contributor

Our organization has a single Log Analytics Workspace that all our subscriptions are connected and sending their logs to.


Currently we must browse to that LA blade in the portal, click Azure Activity Log, find the subscription and the click Connect on the new blade.


Is there a way to automate this?



2 Replies
best response confirmed by AWSullivan (Copper Contributor)


You will need to know the workspace ID. Then use PowerShell. 

Azure AZ module:


New-AzOperationalInsightsAzureActivityLogDataSource -ResourceGroupName <LogAnalyticsOMSWorkspaceResourceGroupName> -WorkspaceName <LogAnalyticsOMSWorkspaceName> -Name <NameOfThisOperationalInsightsAzureActivityLogDataSource> -SubscriptionId <Subscription>


AzureRM module:


New-AzureRmOperationalInsightsAzureActivityLogDataSource -ResourceGroupName <LogAnalyticsOMSWorkspaceResourceGroupName> -WorkspaceName <LogAnalyticsOMSWorkspaceName> -Name <NameOfThisOperationalInsightsAzureActivityLogDataSource> -SubscriptionId <Subscription>








@Craig Wilson Thanks for the response.


This is a great option for us. Do you know if this can be enforced with a DINE policy?