Merge pull request #3705 from sreedharande/master

Added logic to update existing table schemas in ADX
This commit is contained in:
Sreedhar Ande 2021-12-13 19:38:56 -08:00 коммит произвёл GitHub
Родитель 9c7a581fdc da3ea36830
Коммит 16c134e015
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
2 изменённых файлов: 49 добавлений и 36 удалений

Просмотреть файл

@ -140,14 +140,14 @@ function Get-RequiredModules {
Write-Log -Message "Can not install the $Module module. You are not running as Administrator" -LogFileName $LogFileName -Severity Warning
Write-Log -Message "Installing $Module module to current user Scope" -LogFileName $LogFileName -Severity Warning
Install-Module -Name $Module -Scope CurrentUser -Force
Install-Module -Name $Module -Scope CurrentUser -Repository PSGallery -Force -AllowClobber
Import-Module -Name $Module -Force
}
else {
#Admin, install to all users
Write-Log -Message "Installing the $Module module to all users" -LogFileName $LogFileName -Severity Warning
Install-Module -Name $Module -Force -ErrorAction continue
Import-Module -Name $Module -Force -ErrorAction continue
Install-Module -Name $Module -Repository PSGallery -Force -AllowClobber
Import-Module -Name $Module -Force
}
}
# Install-Module will obtain the module from the gallery and install it on your local machine, making it available for use.
@ -654,7 +654,7 @@ catch {
}
#region ADXTableCreation
$LaTablesQuestion = "Do you want to create ADX Raw and Mapping tables for all tables in Log Analytics workspace: $($LogAnalyticsWorkspaceName)?"
$LaTablesQuestion = "Do you want to create/update ADX Raw and Mapping tables for all tables in Log Analytics workspace: $($LogAnalyticsWorkspaceName)"
$LaTablesQuestionChoices = New-Object Collections.ObjectModel.Collection[Management.Automation.Host.ChoiceDescription]
$LaTablesQuestionChoices.Add((New-Object Management.Automation.Host.ChoiceDescription -ArgumentList '&Yes'))
$LaTablesQuestionChoices.Add((New-Object Management.Automation.Host.ChoiceDescription -ArgumentList '&No'))
@ -690,39 +690,52 @@ $AdxTablesArray = New-Object System.Collections.Generic.List[System.Object]
New-AdxRawMappingTables -LaTables $ResultsAllTables -LaMappingDecision $LaTablesQuestionDecision
#endregion
#region EventHubsCreation
Write-Verbose " There are $($AdxTablesArray.ToArray().Count) supported tables to map."
$CreateOrUpdateQuestion = "Are you updating existing table schemas in Azure Data Explorer(ADX)? If you are running this Script for the first time to integrate ADX, Select No"
$CreateOrUpdateQuestionChoices = New-Object Collections.ObjectModel.Collection[Management.Automation.Host.ChoiceDescription]
$CreateOrUpdateQuestionChoices.Add((New-Object Management.Automation.Host.ChoiceDescription -ArgumentList '&Yes'))
$CreateOrUpdateQuestionChoices.Add((New-Object Management.Automation.Host.ChoiceDescription -ArgumentList '&No'))
if ($AdxTablesArray.ToArray().Count -gt 0) {
$AdxMappedTables = Split-ArrayBySize -AdxTabsArray $AdxTablesArray.ToArray() -ArraySize 10
Write-Verbose "Executing: New-EventHubNamespace -ArraysObject $AdxMappedTables"
$EventHubsForADX = New-EventHubNamespace -ArraysObject $AdxMappedTables
$CreateOrUpdateQuestionDecision = $Host.UI.PromptForChoice($title, $CreateOrUpdateQuestion, $CreateOrUpdateQuestionChoices, 1)
if ($CreateOrUpdateQuestionDecision -eq 1) {
#region EventHubsCreation
Write-Verbose " There are $($AdxTablesArray.ToArray().Count) supported tables to map."
if ($AdxTablesArray.ToArray().Count -gt 0) {
$AdxMappedTables = Split-ArrayBySize -AdxTabsArray $AdxTablesArray.ToArray() -ArraySize 10
Write-Verbose "Executing: New-EventHubNamespace -ArraysObject $AdxMappedTables"
$EventHubsForADX = New-EventHubNamespace -ArraysObject $AdxMappedTables
}
else {
Write-Log "There are $($AdxTablesArray.ToArray().Count) supported tables to map in $($LogAnalyticsWorkspaceName), you must choose a workspace with at least one supported table." -LogFileName $LogFileName -Severity Error
exit
}
#endregion
#region LogAnalyticsDataExportRule
New-LaDataExportRule -AdxEventHubs $EventHubsForADX -TablesArrayCollection $AdxMappedTables
#endregion
#region ADXDataConnectionRule
$DataConnectionQuestion = "Do you want to create data connection rules in $AdxDBName for each table with corresponding Event Hub topic, TableRaw and TableRawMappings? `
If Yes, the script will wait for 30 minutes, If No, you must create the data connection rules manually."
$DataConnectionQuestionChoices = New-Object Collections.ObjectModel.Collection[Management.Automation.Host.ChoiceDescription]
$DataConnectionQuestionChoices.Add((New-Object Management.Automation.Host.ChoiceDescription -ArgumentList '&Yes'))
$DataConnectionQuestionChoices.Add((New-Object Management.Automation.Host.ChoiceDescription -ArgumentList '&No'))
$DataConnectionQuestionDecision = $Host.UI.PromptForChoice($title, $DataConnectionQuestion, $DataConnectionQuestionChoices, 0)
if ($DataConnectionQuestionDecision -eq 0) {
Start-SleepMessage -Seconds 1800 -waitMessage "Provisioning Event Hub topics for Log Analytics tables"
New-ADXDataConnectionRules -AdxEventHubs $EventHubsForADX
}
else {
Write-Log -Message "Please manually create data connection rules for $AdxDBName in $AdxEngineUrl" -LogFileName $LogFileName -Severity Warning
}
#endregion
}
else {
Write-Log "There are $($AdxTablesArray.ToArray().Count) supported tables to map in $($LogAnalyticsWorkspaceName), you must choose a workspace with at least one supported table." -LogFileName $LogFileName -Severity Error
Write-Log "Table schemas has been updated" -LogFileName $LogFileName -Severity Information
exit
}
#endregion
#region LogAnalyticsDataExportRule
New-LaDataExportRule -AdxEventHubs $EventHubsForADX -TablesArrayCollection $AdxMappedTables
#endregion
#region ADXDataConnectionRule
$DataConnectionQuestion = "Do you want to create data connection rules in $AdxDBName for each table with corresponding Event Hub topic, TableRaw and TableRawMappings? `
If Yes, the script will wait for 30 minutes, If No, you must create the data connection rules manually."
$DataConnectionQuestionChoices = New-Object Collections.ObjectModel.Collection[Management.Automation.Host.ChoiceDescription]
$DataConnectionQuestionChoices.Add((New-Object Management.Automation.Host.ChoiceDescription -ArgumentList '&Yes'))
$DataConnectionQuestionChoices.Add((New-Object Management.Automation.Host.ChoiceDescription -ArgumentList '&No'))
$DataConnectionQuestionDecision = $Host.UI.PromptForChoice($title, $DataConnectionQuestion, $DataConnectionQuestionChoices, 0)
if ($DataConnectionQuestionDecision -eq 0) {
Start-SleepMessage -Seconds 1200 -waitMessage "Provisioning Event Hub topics for Log Analytics tables"
New-ADXDataConnectionRules -AdxEventHubs $EventHubsForADX
}
else {
Write-Log -Message "Please manually create data connection rules for $AdxDBName in $AdxEngineUrl" -LogFileName $LogFileName -Severity Warning
}
#endregion
}

Двоичные данные
Tools/AzureDataExplorer/Migrate-LA-to-ADX.zip

Двоичный файл не отображается.