SOLVED

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?

 

Thanks!

2 Replies
best response confirmed by AWSullivan (Copper Contributor)
Solution

@AWSullivan 

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

Azure AZ module:

https://docs.microsoft.com/en-us/powershell/module/az.operationalinsights/new-azoperationalinsightsa...

 

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

 

AzureRM module:

https://docs.microsoft.com/en-us/powershell/module/azurerm.operationalinsights/New-AzureRmOperationa...

 

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

 

 

Cheers

 

Craig

 

 

@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?

1 best response

Accepted Solutions
best response confirmed by AWSullivan (Copper Contributor)
Solution

@AWSullivan 

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

Azure AZ module:

https://docs.microsoft.com/en-us/powershell/module/az.operationalinsights/new-azoperationalinsightsa...

 

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

 

AzureRM module:

https://docs.microsoft.com/en-us/powershell/module/azurerm.operationalinsights/New-AzureRmOperationa...

 

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

 

 

Cheers

 

Craig

 

 

View solution in original post