question

KATHIR-8667 avatar image
0 Votes"
KATHIR-8667 asked KATHIR-8667 commented

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

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-databaseazure-automation
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi @KATHIR-8667, just wanted to follow up on the thread if any more information is needed. You can mark @AlbertoMorillo answer as 'Accept Answer' if that helped.

0 Votes 0 ·

1 Answer

AlbertoMorillo avatar image
0 Votes"
AlbertoMorillo answered KATHIR-8667 commented

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.



· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi Alberto ,

Thanks for the support. How to create PowerShell Workflow Runbook on Azure Automation . Kindly share us the code if any for the multiple databases to configure.

0 Votes 0 ·

I updated my response. Let me know if you need more information.

0 Votes 0 ·