Use Azure Automation Hybrid manage local SQL Server backup status (b)

Previous blog post to tell you what is Automation Hybrid Runbook worker and how to use an automated way to deploy it to other local data center or cloud environment. Next will bring everyone together look at how to use Automation Hybrid Runbook worker to perform automated management at the local data center.
The experiments we will use Automation Hybrid Runbook worker run a script to monitor the backup status of a local database, and all will be back to the state of the database backup log analytics for analysis in question is found that some e-mail alerts.
Without further ado Xu, let's start today's test:
test scripts health:
Before we generally use Hybrid Runbook Worker, you need to test script is functioning correctly locally:
Use Azure Automation Hybrid manage local SQL Server backup status (b)

Configuration Automation accounts
believed often to complete some task automation through scripting friends are more clearly related to the user name and other information stored in clear text within the script to execute when the script is great security risks. To avoid this risk, the azure automated account we can add the corresponding certificates and variables to store user name and password information.
First, we set the variables to store the password for the local database:
Use Azure Automation Hybrid manage local SQL Server backup status (b)
then set the user name information certificates to store a local database:
Use Azure Automation Hybrid manage local SQL Server backup status (b)
After the above configurations are completed, we can switch to Runbook tab to create a new runbook:
Use Azure Automation Hybrid manage local SQL Server backup status (b)
After the creation is complete click the "Edit" and then copy the script file to our internal and fine-tuning:
Use Azure Automation Hybrid manage local SQL Server backup status (b)
after configuring the script file we can click "start" to test the operational status of the script:
Use Azure Automation Hybrid manage local SQL Server backup status (b)
there are two options in the run setup:
Azure: this option represents only inside Azure run runbook script
Hybrid worker: this option represents the goods may be other local data center cloud platform to run runbook script
If you choose to use the Hybrid worker, then we need to specify the need to run the script Hybrid worker group:
Use Azure Automation Hybrid manage local SQL Server backup status (b)
we can see the corresponding log in the console after the configuration operating status:
Use Azure Automation Hybrid manage local SQL Server backup status (b)
we also can execute queries in the log analytics, sub-state corresponds to view information such as:
AzureDiagnostics | where RunbookName_s == "GetSQLBackupStatus" | where ResultDescription contains "Backup" | parse ResultDescription with "SQLServerName: "SQLServerName", Database:"Database", Last Backup Finish Date (UTC): '" BackupFinishedDateUTC:datetime "'"* | project SQLServerName, Database, BackupFinishedDateUTC, TimeGenerated | where BackupFinishedDateUTC <= ago(2d)
Use Azure Automation Hybrid manage local SQL Server backup status (b)

查询剩余空间百分比低于20%的数据库:
AzureDiagnostics | where RunbookName_s == "GetSQLBackupStatus" | where ResultDescription contains "Free Space" | parse ResultDescription with "SQLServerName:"SQLServerName", Database:"Database", Current Size MB:"CurrentSizeMB", Free Space MB:"FreeSpaceMB", Free Space Percentage:" FreeSpacePercent:long * | project SQLServerName, Database, CurrentSizeMB, FreeSpaceMB, FreeSpacePercent, TimeGenerated | where FreeSpacePercent < 20
Use Azure Automation Hybrid manage local SQL Server backup status (b)

Configure Alerts
In addition to these functions, we can use Azure Montior configure mail alert to potential problems in time.
Entering Azure Monitor, click Alert, click on the "+ new alert rule":
Use Azure Automation Hybrid manage local SQL Server backup status (b)
shown below configuration:
Use Azure Automation Hybrid manage local SQL Server backup status (b)
Use Azure Automation Hybrid manage local SQL Server backup status (b)

After the configuration, as shown below:
Use Azure Automation Hybrid manage local SQL Server backup status (b)
When the percentage of free space database less than 20%, we'll get a message corresponding to the alert message:

Use Azure Automation Hybrid manage local SQL Server backup status (b)

Guess you like

Origin blog.51cto.com/wuyvzhang/2465448