Workspace reconfiguration via ARM or Powershell?

%3CLINGO-SUB%20id%3D%22lingo-sub-1028550%22%20slang%3D%22en-US%22%3EWorkspace%20reconfiguration%20via%20ARM%20or%20Powershell%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1028550%22%20slang%3D%22en-US%22%3E%3CP%3EI%20have%20150ish%20subscriptions%20that%20are%20already%20configured%20with%20workspaces.%20I%20need%20to%20create%20a%20new%20workspace%20and%20have%20all%20the%20VMs%20get%20reconfigured.%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI've%20tested%20that%20this%20will%20work%20given%20time%20via%20manually%20changing%20the%20workspace%20and%20saying%20yes%20to%20the%20reconfigure%20popup%20in%20the%20portal.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI've%20tested%20with%20ARM%20templates%20and%20with%20powershell%20but%20it%20does%20not%20appear%20that%20the%20reconfiguration%20happens.%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIs%20this%20expected%20behavior%2C%20or%20will%20I%20need%20to%20look%20at%20running%20commands%20on%20all%20the%20VMs%20with%20the%20workspace%20id%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1029399%22%20slang%3D%22en-US%22%3ERe%3A%20Workspace%20reconfiguration%20via%20ARM%20or%20Powershell%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1029399%22%20slang%3D%22en-US%22%3E%3CP%3EHi%20%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F311322%22%20target%3D%22_blank%22%3E%40yoavfrancis%3C%2FA%3E%26nbsp%3Bthanks%20for%20the%20reply.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20think%20I%20may%20just%20need%20some%20clarification.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIs%20the%20POST%20doing%20anything%20different%20than%20the%20following%20would%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CDIV%3E%3CDIV%3E%3CSPAN%3ESet-AzSecurityWorkspaceSetting%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3E-%3C%2FSPAN%3E%3CSPAN%3EName%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3E%22default%22%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3E-%3C%2FSPAN%3E%3CSPAN%3EScope%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3E%22%2Fsubscriptions%2F%24subscriptionid%22%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3E-%3C%2FSPAN%3E%3CSPAN%3EWorkspaceId%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3E%22%2Fsubscriptions%2F%24subscriptionid%2Fresourcegroups%2F%24rg_name%2Fproviders%2Fmicrosoft.operationalinsights%2Fworkspaces%2F%24workspace_name%22%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3EIf%20not%2C%20then%20are%20you%20saying%20if%20the%20workspace%20is%20still%20default%20(aka%20was%20never%20changed)%20it%20will%20reconfigure%20the%20VMs%2C%20but%20if%20it%20was%20changed%20to%20a%20custom%20workspace%2C%20running%20the%20above%20powershell%20or%20API%20will%20not%20reconfigure%20the%20VMs%3F%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3EThanks%2C%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3ENathan%3C%2FSPAN%3E%3C%2FDIV%3E%3C%2FDIV%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1029107%22%20slang%3D%22en-US%22%3ERe%3A%20Workspace%20reconfiguration%20via%20ARM%20or%20Powershell%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1029107%22%20slang%3D%22en-US%22%3E%3CP%3EHi%20%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F437206%22%20target%3D%22_blank%22%3E%40nathanmitten%3C%2FA%3E%2C%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThanks%20for%20reaching%20out.%20%3CSTRONG%3EIf%20your%20subscriptions%20are%20currently%20using%20Security%20Center's%20managed%20workspaces%3C%2FSTRONG%3E%20(default%20workspaces)%20and%20you'd%20like%20to%20change%20them%20to%20report%20to%20a%20workspace%20of%20your%20own%2C%20you%20can%20reconfigure%20your%20existing%20VMs%20to%20report%20to%20this%20new%20workspace%20programmatically%20by%20using%20REST%20API%3A%3C%2FP%3E%0A%3CP%3E%3CU%3EHTTP%20Method%3C%2FU%3E%3A%20%3CEM%3EPOST%3C%2FEM%3E%3C%2FP%3E%0A%3CP%3E%3CU%3EURI%3C%2FU%3E%3A%26nbsp%3B%3CEM%3E%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fnam06.safelinks.protection.outlook.com%2F%3Furl%3Dhttps%253A%252F%252Fmanagement.azure.com%252Fsubscriptions%252F%25257bsubscriptionId%25257d%252Fproviders%252FMicrosoft.Security%252FworkspaceSettings%252Fdefault%252Fconnect%253Fapi-version%253D2017-08-01-preview%26amp%3Bdata%3D02%257C01%257Cyoafr%2540microsoft.com%257C58f833fb27ef403d7a7408d6f5a508d8%257C72f988bf86f141af91ab2d7cd011db47%257C1%257C0%257C636966486497925702%26amp%3Bsdata%3DKlvSogBqrZL%252BliDeySQONzxqMsHNKfMhGEQufRFXJu0%253D%26amp%3Breserved%3D0%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noreferrer%22%3E%3CSPAN%20style%3D%22font-weight%3A%20inherit%20!important%3B%22%3Ehttps%3A%2F%2Fmanagement.azure.com%2Fsubscriptions%2F%7BsubscriptionId%7D%2Fproviders%2FMicrosoft.Security%2FworkspaceSettings%2Fdefault%2Fconnect%3Fapi-version%3D2017-08-01-preview%3C%2FSPAN%3E%3C%2FA%3E%3C%2FEM%3E%3C%2FP%3E%0A%3CP%3E%3CU%3E%3CSPAN%20style%3D%22font-style%3A%20inherit%20!important%3B%20font-weight%3A%20inherit%20!important%3B%22%3ERequest%20Body%3A%3C%2FSPAN%3E%3C%2FU%3E%3C%2FP%3E%0A%3CP%3E%3CEM%3E%3CSPAN%20style%3D%22font-weight%3A%20inherit%20!important%3B%22%3E%2Fsubscriptions%2F%7BsubscriptionId%7D%2FresourceGroups%2F%7BresourceGroupName%7D%2Fproviders%2FMicrosoft.OperationalInsights%2Fworkspaces%2F%7BworkspaceName%7D%3C%2FSPAN%3E%3C%2FEM%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EReconfiguration%20of%20the%20agents%20may%20take%20up%20to%2012%20hours.%3C%2FP%3E%0A%3CP%3E%3CSPAN%20style%3D%22font-weight%3A%20inherit%20!important%3B%22%3EAlternatively%20you%20can%20see%20the%20same%20in%20the%20ASC%20Portal%20experience%3A%20Pricing%20%26amp%3B%20Settings%20-%26gt%3B%20Select%20subscription%20-%26gt%3B%20Data%20collection%20-%26gt%3B%20switch%20from%20default%20workspaces%20to%20a%20workspace%20of%20your%20own.%20You'll%20then%20see%20the%20following%20confirmation%20dialog%20(Of%20course%20this%20method%20is%20applicable%20only%20in%20case%20you%20want%20to%20alter%20a%20few%20subscriptions%20and%20not%20dozens)%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20770px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F158656iE7397596D1B03163%2Fimage-dimensions%2F770x175%3Fv%3D1.0%22%20width%3D%22770%22%20height%3D%22175%22%20alt%3D%22clipboard_image_0.png%22%20title%3D%22clipboard_image_0.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%20style%3D%22font-weight%3A%20inherit%20!important%3B%22%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3EWe%20plan%20to%20add%20this%20to%20our%20API%20documentation%20in%20the%20near%20future%20as%20this%20specific%20functionality%20is%20missing%20from%20it%2C%20along%20with%20adding%20this%20to%20our%20PowerShell%20snippet.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3EIf%20your%20VMs%20currently%20report%20to%20your%20own%20workspace%3C%2FSTRONG%3E%20(whether%20the%20Microsoft%20Monitoring%20agent%20was%20provisioned%20manually%20on%20your%20VMs%20or%20with%20ASC's%20automatic%20provisioning)%2C%20you'll%20have%20to%20reconfigure%20the%20Microsoft%20Monitoring%20agent%20to%20the%20new%20workspace%20manually.%20ASC%20can't%20do%20this%20automatically%20for%20you%20since%20it%20did%20not%20necessarily%20provision%20the%20agent%20and%20the%20actual%20reporting%20to%20the%20(user)%20workspace%20may%20have%20served%20needs%20besides%20ASC%20-%20thus%20this%20can't%20be%20done%20automatically.%3C%2FP%3E%0A%3CP%3EReconfiguration%20in%20this%20case%20can%20be%20done%20in%20multiple%20ways%2C%20but%20this%20depend%20on%20how%20the%20Microsoft%20Monitoring%20Agent%20was%20installed%20(as%20an%20Azure%20Extension%20or%20as%20a%20Direct%20Agent%20installation)%20and%20on%20the%20OS.%20Please%20consult%20the%20relevant%20docs%20in%20such%20a%20case%20to%20find%20your%20appropriate%20scenario%3A%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fazure-monitor%2Fplatform%2Flog-analytics-agent%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ehttps%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fazure-monitor%2Fplatform%2Flog-analytics-agent%3C%2FA%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EPlease%20reach%20out%20if%20you%20have%20any%20further%20questions%20or%20required%20clarifications.%3C%2FP%3E%0A%3CP%3EThanks%2C%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EYoav%20Francis%2C%3C%2FP%3E%0A%3CP%3ESenior%20Product%20Manager%2C%20Azure%20Security%20Center%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1044160%22%20slang%3D%22en-US%22%3ERe%3A%20Workspace%20reconfiguration%20via%20ARM%20or%20Powershell%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1044160%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F437206%22%20target%3D%22_blank%22%3E%40nathanmitten%3C%2FA%3E%26nbsp%3BApologies%20for%20the%20delay.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%3E%3CEM%3ESet-AzSecurityWorkspaceSetting%3C%2FEM%3E%20controls%20in%20which%20workspace%20to%20save%20the%20data%2C%20in%20case%20auto%20provisioning%20was%20enabled%20(with%20%3CEM%3ESet-AzSecurityAutoProvisioningStatus%3C%2FEM%3E).%20In%20case%20you're%20using%20auto%20provisioning%20with%20managed%20workspaces%20('%3C%2FSPAN%3E%3CSPAN%3Edefault'%20workspaces)%2C%20no%20need%20to%20call%26nbsp%3B%3CEM%3ESet-AzSecurityWorkspaceSetting%26nbsp%3B%3C%2FEM%3Eat%20all.%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%3ENeither%20of%20the%20above%20PowerShell%20cmdlets%20take%20care%20of%20reconnecting%20the%20VMs%20in%20case%20you%20move%20from%20auto%20provisioning%20on%20default%20workspace%20to%20auto%20provisioning%20on%20a%20central%20workspace.%20In%20order%20to%20reconnect%20the%20VMs%20you'll%20need%20to%20explicitly%20make%20a%20POST%20call%20to%20the%20URI%20I%20mentioned%20in%20my%20last%20post%3A%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CEM%3E%3CA%20href%3D%22https%3A%2F%2Fmanagement.azure.com%2Fsubscriptions%2F%257bsubscriptionId%257d%2Fproviders%2FMicrosoft.Security%2FworkspaceSettings%2Fdefault%2Fconnect%3Fapi-version%3D2017-08-01-preview%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fmanagement.azure.com%2Fsubscriptions%2FSUBSCRIPTION_ID%2Fproviders%2FMicrosoft.Security%2FworkspaceSettings%2Fdefault%2Fconnect%3Fapi-version%3D2017-08-01-preview%3C%2FA%3E%26nbsp%3B%3C%2FEM%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThanks%2C%3C%2FP%3E%0A%3CP%3EYoav%3C%2FP%3E%3C%2FLINGO-BODY%3E
Occasional Contributor

I have 150ish subscriptions that are already configured with workspaces. I need to create a new workspace and have all the VMs get reconfigured. 

 

I've tested that this will work given time via manually changing the workspace and saying yes to the reconfigure popup in the portal.

 

I've tested with ARM templates and with powershell but it does not appear that the reconfiguration happens. 

 

Is this expected behavior, or will I need to look at running commands on all the VMs with the workspace id?

3 Replies

Hi @nathanmitten,

 

Thanks for reaching out. If your subscriptions are currently using Security Center's managed workspaces (default workspaces) and you'd like to change them to report to a workspace of your own, you can reconfigure your existing VMs to report to this new workspace programmatically by using REST API:

HTTP Method: POST

URI https://management.azure.com/subscriptions/{subscriptionId}/providers/Microsoft.Security/workspaceSe...

Request Body:

/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}

 

Reconfiguration of the agents may take up to 12 hours.

Alternatively you can see the same in the ASC Portal experience: Pricing & Settings -> Select subscription -> Data collection -> switch from default workspaces to a workspace of your own. You'll then see the following confirmation dialog (Of course this method is applicable only in case you want to alter a few subscriptions and not dozens)

 

clipboard_image_0.png

 

We plan to add this to our API documentation in the near future as this specific functionality is missing from it, along with adding this to our PowerShell snippet.

 

 

If your VMs currently report to your own workspace (whether the Microsoft Monitoring agent was provisioned manually on your VMs or with ASC's automatic provisioning), you'll have to reconfigure the Microsoft Monitoring agent to the new workspace manually. ASC can't do this automatically for you since it did not necessarily provision the agent and the actual reporting to the (user) workspace may have served needs besides ASC - thus this can't be done automatically.

Reconfiguration in this case can be done in multiple ways, but this depend on how the Microsoft Monitoring Agent was installed (as an Azure Extension or as a Direct Agent installation) and on the OS. Please consult the relevant docs in such a case to find your appropriate scenario: https://docs.microsoft.com/en-us/azure/azure-monitor/platform/log-analytics-agent

 

Please reach out if you have any further questions or required clarifications.

Thanks,

 

Yoav Francis,

Senior Product Manager, Azure Security Center 

Hi @yoavfrancis thanks for the reply.

 

I think I may just need some clarification.

 

Is the POST doing anything different than the following would?

 

Set-AzSecurityWorkspaceSetting -Name "default" -Scope "/subscriptions/$subscriptionid" -WorkspaceId "/subscriptions/$subscriptionid/resourcegroups/$rg_name/providers/microsoft.operationalinsights/workspaces/$workspace_name"
 
If not, then are you saying if the workspace is still default (aka was never changed) it will reconfigure the VMs, but if it was changed to a custom workspace, running the above powershell or API will not reconfigure the VMs?
 
Thanks,
 
Nathan

@nathanmitten Apologies for the delay.

 

Set-AzSecurityWorkspaceSetting controls in which workspace to save the data, in case auto provisioning was enabled (with Set-AzSecurityAutoProvisioningStatus). In case you're using auto provisioning with managed workspaces ('default' workspaces), no need to call Set-AzSecurityWorkspaceSetting at all.

 

Neither of the above PowerShell cmdlets take care of reconnecting the VMs in case you move from auto provisioning on default workspace to auto provisioning on a central workspace. In order to reconnect the VMs you'll need to explicitly make a POST call to the URI I mentioned in my last post:

https://management.azure.com/subscriptions/SUBSCRIPTION_ID/providers/Microsoft.Security/workspaceSet... 

 

 

 

Thanks,

Yoav