First published on MSDN on Jan 15, 2018 To provide complete solution to maintain you Azure SQL DB statistics and maintenance we provide our maintenance script here In this article, we will explain step by step how to automate this maintenance on Azure (You can also use that to automate your own T-SQL tasks) General steps:
Step by step instructions:
$AzureSQLServerName = "<ServerName>"
$AzureSQLDatabaseName = "<DatabaseName>"
$AzureSQLServerName = $AzureSQLServerName + ".database.windows.net"
$Cred = Get-AutomationPSCredential -Name "SQLLogin"
$SQLOutput = $(Invoke-Sqlcmd -ServerInstance $AzureSQLServerName -Username $Cred.UserName -Password $Cred.GetNetworkCredential().Password -Database $AzureSQLDatabaseName -Query "exec [dbo].[AzureSQLMaintenance] @Operation='all' ,@LogToTable=1" -QueryTimeout 65535 -ConnectionTimeout 60 -Verbose) 4>&1
Monitoring you can monitor the success of the job by reviewing the Automation overview page Figure 10 – Job Overview. then you can click on each category and drill down... Figure 11 – Job executions then you can click on a specific execution and get more details about it including the output of the script Figure 12 – Details of job execution and output information. I hope you enjoy this post, please share any thoughts on a comment here in this post. Notes:
More information: Getting Started with Azure Automation Create a standalone Azure Automation account My first PowerShell runbook
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.