Sunday, December 22, 2019

Data Platform Tips 25 - Azure Elastic Jobs

Elastic Job agent conceptual modelAzure Elastic Jobs allows you to create and schedule jobs to perform maintenance jobs on the Azure SQL Databases. Jobs can run across multiple servers, multiple pools and databases in different Azure Subscriptions. Note: Elastic Jobs are currently in Preview.

Elastic Job has multiple components.


  • Elastic Job Agent - Azure resource responsible for creating, running and managing jobs. An existing Azure SQL Database (S0 or higher) is required to create Job Agent.
  • Job Database - Used to define jobs, track status and history of job executions. An existing Azure SQL Database (S0 or higher) is required to create a Job database.
  • Target Group - Defines a set of databases a job step will execute on. A Target group may contain SQL Database Servers, Elastic Pools, Single Database or databases of Shardmap.
  • Job - Unit of work that is executed on a schedule or as a one-time activity. A job contains one or more steps. 

Creating an Elastic Job using the Azure Portal


Elastic Jobs credentials
a) Log on to the Azure Portal

b) Provision a Standard S1 Azure SQL Database named "ElasticJob" and this is your Job Database.























c) Create an Elastic Job Agent.



































d) Connect to the Job Database "ElasticJob" and run the following queries.











e) Connect to the master Database of the target server against which the job needs to be executed and create the logins for "MasterCredential" and "JobCredential" and user for "MasterCredential".







f) Create user "JobCredential" in the target database "Database1".







g) Create target group and members on the "ElasticJob" Job database, the databases you want the job to run against. The target can be either single database, server or elastic pool.











h) Now you can create the Job and Job Steps in the "ElasticJob" Job Database.











i) Execute the Job manually.











j) Check for the Job status.











h) Finally you can schedule the job.


No comments:

Post a Comment