Need to configure the Maintenance plan for themultiple databases in azure automation accounts using powershell.

KATHIR 21 Reputation points
2021-06-18T20:19:25.01+00:00

HI Team,

Need to configure the Maintenance plan for the multiple databases in azure automation accounts using powershell.

Note : I am able to configure for the single databases and it is working fine (rebuild index and update stats)

Service : SQL Databases.

Azure SQL Database
Azure Automation
Azure Automation
An Azure service that is used to automate, configure, and install updates across hybrid environments.
1,153 questions
{count} votes

Accepted answer
  1. Alberto Morillo 33,171 Reputation points MVP
    2021-06-18T20:36:25.207+00:00

    The way I do that is I create Ola Hallengren scripts on each database, then I create one PowerShell Workflow Runbook on Azure Automation that execute stored procedures on databases, after that I just need to create the different schedules on Azure Automation that will perform all maintenance tasks by executing Ola's scripts (stored procedures) or any other stored procedure created for maintenance purposes.

     $DatabaseCommand = New-Object System.Data.SqlClient.SqlCommand
     $DatabaseCommand.CommandType = [System.Data.CommandType]::StoredProcedure
     $DatabaseCommand.Connection = $DatabaseConnection
     # A value of 0 indicates no limit
     $DatabaseCommand.CommandTimeout = 0
     $DatabaseCommand.CommandText = $SP
    

    Set the time out to zero to avoid timeout errors.


0 additional answers

Sort by: Most helpful