diff --git a/Azure Services/Azure Monitor/Agents/Migration Tools/DCR Config Generator/DCRGenerator-README.md b/Azure Services/Azure Monitor/Agents/Migration Tools/DCR Config Generator/DCRGenerator-README.md index 9814fc65..282e8c2f 100644 --- a/Azure Services/Azure Monitor/Agents/Migration Tools/DCR Config Generator/DCRGenerator-README.md +++ b/Azure Services/Azure Monitor/Agents/Migration Tools/DCR Config Generator/DCRGenerator-README.md @@ -17,28 +17,33 @@ These instructions will help you get started with running the Migration Tool scr - Powershell version 7.1.3 or higher is recommended (minimum version 5.1) - Primarily uses Az Powershell module to pull workspace agent configuration information - User will need Read access for the specified workspace resource -- Connect-AzAccount and Select-AzSubscription will be used to set the context for the script to run so proper Azure credentials will be needed +- `Connect-AzAccount` and `Select-AzSubscription` will be used to set the context for the script to run so proper Azure credentials will be needed ## Running the application - Inputs for the Migration Tool Script - There are 6 parameters for the script with 5 being required - - SubscriptionId: Subscription Id that contains the target workspace - - ResourceGroupName: Resource Group that contains the target workspace - - WorkspaceName: Name of the target workspace - - DCRName: Name of the new DCR to create - - Location: Region location for the new DCR - - FolderPath (Optional): Local path to store the output. Current directory will be used if nothing is provided. + + | Parameter Name | Description | + |-------------------------|-----------------------------------------------------------------------------------------| + | *SubscriptionId* | Subscription Id that contains the target workspace | + | *ResourceGroupName* | Resource Group that contains the target workspace | + | *WorkspaceName* | Name of the target workspace | + | *DCRName* | Name of the new DCR to create | + | *Location* | Region location for the new DCR. | + | *FolderPath (Optional)* | Local path to store the output. Current directory will be used if nothing is provided. | - Instructions to Run the Script - Running the script is straightforward. Use the script location along with at least the 5 required parameters. - Option #1: - - Example: .\WorkspaceConfigToDCRMigrationTool.ps1 -SubscriptionId $subId -ResourceGroupName $rgName -WorkspaceName $workspaceName -DCRName $dcrName -Location $location -FolderPath $folderPath + ```PowerShell + .\WorkspaceConfigToDCRMigrationTool.ps1 -SubscriptionId $subId -ResourceGroupName $rgName -WorkspaceName $workspaceName -DCRName $dcrName -Location $location -FolderPath $folderPath + ``` - Option #2 (if you are just looking for the DCR payload json): - - Example: - $dcrJson = Get-DCRJson -ResourceGroupName $rgName -WorkspaceName $workspaceName -PlatformType $platformType - $dcrJson | ConvertTo-Json -Depth 10 | Out-File "C:\One\OutputFiles\dcr_output.json" - + ```PowerShell + $dcrJson = Get-DCRJson -ResourceGroupName $rgName -WorkspaceName $workspaceName -PlatformType $platformType + $dcrJson | ConvertTo-Json -Depth 10 | Out-File "C:\One\OutputFiles\dcr_output.json" + ``` - Output for the Script - There are two separate ARM templates that can be produced (based on agent configuration of the target workspace): - Windows ARM Template and Parameter Files: will be created if target workspace contains Windows Performance Counters and/or Windows Events diff --git a/Azure Services/Azure Monitor/Agents/Migration Tools/DCR Config Generator/WorkspaceConfigToDCRMigrationTool.ps1 b/Azure Services/Azure Monitor/Agents/Migration Tools/DCR Config Generator/WorkspaceConfigToDCRMigrationTool.ps1 index 840b5da3..2688c983 100644 --- a/Azure Services/Azure Monitor/Agents/Migration Tools/DCR Config Generator/WorkspaceConfigToDCRMigrationTool.ps1 +++ b/Azure Services/Azure Monitor/Agents/Migration Tools/DCR Config Generator/WorkspaceConfigToDCRMigrationTool.ps1 @@ -51,7 +51,7 @@ function Get-UserWorkspace [Parameter(Mandatory=$true)][string] $WorkspaceName ) - $workspace = Get-AzOperationalInsightsWorkspace -ResourceGroupName $rgNameWorkspace -Name $workspaceName + $workspace = Get-AzOperationalInsightsWorkspace -ResourceGroupName $ResourceGroupName -Name $workspaceName return $workspace } @@ -123,7 +123,7 @@ function Get-DCRArmTemplate [Parameter(Mandatory=$true)][string] $FolderPath ) - $dcrJson = Get-DCRJson -ResourceGroupName $rgNameWorkspace -WorkspaceName $workspaceName -PlatformType $PlatformType + $dcrJson = Get-DCRJson -ResourceGroupName $ResourceGroupName -WorkspaceName $workspaceName -PlatformType $PlatformType #ARM Template File $schema = "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#" @@ -595,13 +595,12 @@ function Get-DataFlows return $dataFlows } - -Connect-AzAccount -Select-AzSubscription -Subscription $subId - -$rgNameWorkspace = 'rg-jamui-workspace' -$workspaceName = 'workspace-jamui-1' - +#Requires -Modules Az.Accounts, Az.OperationalInsights +# connect if we dont the context already. +if ($null -eq (Get-AzContext | Where-Object {$_.Subscription.id -eq $SubscriptionId})) { +Connect-AzAccount | out-null +Select-AzSubscription -Subscription $subId | out-null +} Write-Output "Subscription Id: $($SubscriptionId)" Write-Output "Resource Group: $($ResourceGroupName)" Write-Output "Workspace Name: $($WorkspaceName)"