You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: azure-sql/database/elastic-jobs-overview.md
+6-2Lines changed: 6 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,7 +4,7 @@ description: "Learn about how you can use elastic jobs to run Transact-SQL (T-SQ
4
4
author: WilliamDAssafMSFT
5
5
ms.author: wiassaf
6
6
ms.reviewer: srinia
7
-
ms.date: 11/06/2023
7
+
ms.date: 11/13/2023
8
8
ms.service: sql-database
9
9
ms.subservice: elastic-jobs
10
10
ms.topic: overview
@@ -171,6 +171,7 @@ For more information on UMI in Azure SQL Database, see [Managed identities for A
171
171
172
172
> [!IMPORTANT]
173
173
> When using Microsoft Entra ID authentication, create your `jobuser` user from that Microsoft Entra ID in every target database. Grant that user the permissions needed to execute your job(s) in each target database.
174
+
174
175
Using a system-assigned managed identity (SMI) is not supported.
175
176
176
177
### Authentication via database-scoped credentials
@@ -222,6 +223,9 @@ During job agent creation, a schema, tables, and a role called *jobs_reader* are
222
223
|---------|---------|---------|
223
224
|**jobs_reader**| SELECT | None |
224
225
226
+
> [!CAUTION]
227
+
> You should not update internal catalog views in the *job database*, such as [jobs.target_group_members](/sql/relational-databases/system-catalog-views/jobs-target-group-members-elastic-jobs-transact-sql?view=azuresqldb-current&preserve-view=true). Manually changing these catalog views can corrupt the *job database* and cause failure. These views are for read-only querying only. You can use the stored procedures on your *job database* to add/delete target groups/members, such as [jobs.sp_add_target_group_member](/sql/relational-databases/system-stored-procedures/sp-add-target-group-member-elastic-jobs-transact-sql?view=azuresqldb-current&preserve-view=true).
228
+
225
229
> [!IMPORTANT]
226
230
> Consider the security implications before granting any elevated access to the *job database*. A malicious user with permissions to create or edit jobs could create or edit a job that uses a stored credential to connect to a database under the malicious user's control, which could allow the malicious user to determine the credential's password or execute malicious commands.
227
231
@@ -278,7 +282,7 @@ Most environments require less than 100 concurrent jobs at any time, so JA100 is
278
282
279
283
Exceeding the job agent's concurrency capacity tier with job targets will create queuing delays for some target databases/servers. For example, if you start a job with 110 target in the JA100 tier, 10 jobs will wait to start until others finish.
280
284
281
-
The tier or service objective of an elastic job agent can be modified through the Azure portal, [PowerShell](/powershell/module/az.sql/set-azsqlelasticjobagent), or [the Job Agents REST API](/rest/api/sql/2021-02-01-preview/job-agents).<!-- TODO update /2021-02-01/ when available --> For an example, see [Scale the job agent](elastic-jobs-tutorial.md#scale-the-job-agent).
285
+
The tier or service objective of an elastic job agent can be modified through the Azure portal, [PowerShell](/powershell/module/az.sql/set-azsqlelasticjobagent), or [the Job Agents REST API](/rest/api/sql/job-agents). For an example, see [Scale the job agent](elastic-jobs-tutorial.md#scale-the-job-agent).
Copy file name to clipboardExpand all lines: azure-sql/database/elastic-jobs-powershell-create.md
+63-4Lines changed: 63 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,7 +4,7 @@ description: Learn how to create an elastic job agent and run scripts across man
4
4
author: WilliamDAssafMSFT
5
5
ms.author: wiassaf
6
6
ms.reviewer: srinia
7
-
ms.date: 11/02/2023
7
+
ms.date: 11/14/2023
8
8
ms.service: sql-database
9
9
ms.subservice: elastic-jobs
10
10
ms.topic: tutorial
@@ -35,6 +35,8 @@ In this end-to-end tutorial, you learn the steps required to run a query across
35
35
36
36
Elastic database jobs have a set of PowerShell cmdlets.
37
37
38
+
These cmdlets were updated in November 2023.
39
+
38
40
### Install the latest elastic jobs cmdlets
39
41
40
42
If you don't have an Azure subscription, [create a free account](https://azure.microsoft.com/free/) before you begin.
@@ -169,28 +171,85 @@ An elastic job agent is an Azure resource for creating, running, and managing jo
169
171
170
172
The [New-AzSqlElasticJobAgent](/powershell/module/az.sql/new-azsqlelasticjobagent) cmdlet requires a database in Azure SQL Database to already exist, so the `resourceGroupName`, `serverName`, and `databaseName` parameters must all point to existing resources. Similarly, [Set-AzSqlElasticJobAgent](/powershell/module/az.sql/set-azsqlelasticjobagent) can be used to modify the elastic job agent.
171
173
174
+
To create a new elastic job agent using Microsoft Entra authentication with a user-assigned managed identity, use the `IdentityType` and `IdentityID` arguments of `New-AzSqlElasticJobAgent`:
175
+
172
176
```powershell
173
177
Write-Output "Creating job agent..."
174
178
$agentName = Read-Host "Please enter a name for your new elastic job agent"
To create a new elastic job agent using database-scoped credentials, `IdentityType` and `IdentityID` are not provided.
189
+
182
190
## Create the job authentication
183
191
184
192
The elastic job agent must be able to authenticate to each target server or database.
185
193
186
194
As covered in [Create job agent authentication](elastic-jobs-tutorial.md#create-job-agent-authentication):
187
195
188
-
- Use database users mapped to user-assigned managed identity (UMI) to authenticate to target server(s)/database(s).
189
-
- Using a UMI with Microsoft Entra authentication (formerly Azure Active Directory) is the recommended method.
190
-
-Using PowerShell cmdlets to configure Microsoft Entra authentication is currently not supported. See [Create and manage elastic jobs by using T-SQL (preview)](elastic-jobs-tsql-create-manage.md).
196
+
- Use database users mapped to [user-assigned managed identity (UMI) to authenticate to target server(s)/database(s)](#use-microsoft-entra-authentication-with-a-umi-for-authentication-to-targets).
197
+
- Using a UMI with Microsoft Entra authentication (formerly Azure Active Directory) is the recommended method. PowerShell cmdlets now have new arguments to support Microsoft Entra authentication with a UMI.
198
+
-This is the recommended authentication method.
191
199
- Use database users mapped to [database-scoped credentials](#create-the-job-credentials) in each database.
192
200
- Previously, database-scoped credentials were the only option for the elastic job agent to authenticate to targets.
193
201
202
+
### Use Microsoft Entra authentication with a UMI for authentication to targets
203
+
204
+
To use the recommended method of Microsoft Entra (formerly Azure Active Directory) authentication to a user-assigned managed identity (UMI), follow these steps. The elastic job agent connects to the desired target logical server(s)/databases(s) via Entra authentication.
205
+
206
+
In addition to the login and database users, note the addition of the `GRANT` commands in the following script. These permissions are required for the script we chose for this example job. Your jobs may require different permissions. Because the example creates a new table in the targeted databases, the database user in each target database needs the proper permissions to successfully run.
207
+
208
+
In each of the target server(s)/database(s), create a contained user mapped to the UMI.
209
+
210
+
- If the elastic job has logical server or pool targets, you must create the contained user mapped to the UMI in the `master` database of the target logical server.
211
+
- For example, to create a contained database login in the `master` database, and a user in the user database, based on the user-assigned managed identity (UMI) named `job-agent-UMI`:
212
+
213
+
```powershell
214
+
$targetServer = '<target server name>'
215
+
$adminLogin = '<username>'
216
+
$adminPassword = '<password>'
217
+
218
+
# For the target logical server, in the master database
219
+
# Create the login named [job-agent-UMI] based on the UMI [job-agent-UMI], and a user
$createJobUserScript = "CREATE USER [job-agent-UMI] FROM LOGIN [job-agent-UMI]"
236
+
237
+
# Grant permissions as necessary. For example ALTER and CREATE TABLE:
238
+
$grantAlterSchemaScript = "GRANT ALTER ON SCHEMA::dbo TO [job-agent-UMI]"
239
+
$grantCreateScript = "GRANT CREATE TABLE TO [job-agent-UMI]"
240
+
241
+
$targetDatabases | % {
242
+
$params.database = $_
243
+
$params.query = $createJobUserScript
244
+
Invoke-SqlCmd @params
245
+
$params.query = $grantAlterSchemaScript
246
+
Invoke-SqlCmd @params
247
+
$params.query = $grantCreateScript
248
+
Invoke-SqlCmd @params
249
+
}
250
+
```
251
+
252
+
194
253
### <aid="create-the-job-credentials"></a> Use database-scoped credentials for authentication to targets
195
254
196
255
Job agents use credentials specified by the target group upon execution and execute scripts. These database-scoped credentials are also used to connect to the `master` database to discover all the databases in a server or an elastic pool, when either of these are used as the target group member type.
Copy file name to clipboardExpand all lines: azure-sql/database/elastic-jobs-tsql-create-manage.md
+3-1Lines changed: 3 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,7 +4,7 @@ description: Learn how to create an elastic job agent and run scripts across man
4
4
author: WilliamDAssafMSFT
5
5
ms.author: wiassaf
6
6
ms.reviewer: srinia
7
-
ms.date: 11/06/2023
7
+
ms.date: 11/13/2023
8
8
ms.service: sql-database
9
9
ms.subservice: elastic-jobs
10
10
ms.topic: how-to
@@ -235,6 +235,8 @@ SELECT * FROM jobs.target_group_members WHERE target_group_name = N'PoolGroup';
235
235
236
236
With T-SQL, create jobs using system stored procedures in the jobs database: [jobs.sp_add_job](/sql/relational-databases/system-stored-procedures/sp-add-job-elastic-jobs-transact-sql?view=azuresql-db&preserve-view=true) and [jobs.sp_add_jobstep](/sql/relational-databases/system-stored-procedures/sp-add-jobstep-elastic-jobs-transact-sql?view=azuresql-db&preserve-view=true). The T-SQL commands are syntax are similar to the steps needed to create SQL Agent jobs and job steps in SQL Server.
237
237
238
+
You should not update internal catalog views in the *job database*. Manually changing these catalog views can corrupt the *job database* and cause failure. These views are for read-only querying only. You can use the stored procedures in the `jobs` schema on your *job database*.
239
+
238
240
- When using Microsoft Entra authentication for a Microsoft Entra ID or user-assigned managed identity to authenticate to target server(s)/database(s), the *@credential_name* argument shouldn't be provided for `sp_add_jobstep` or `sp_update_jobstep`. Similarly, omit the optional *@output_credential_name* and *@refresh_credential_name* arguments.
239
241
- When using database-scoped credentials to authenticate to target server(s)/database(s), the *@credential_name* parameter is required for `sp_add_jobstep` and `sp_update_jobstep`.
240
242
- For example, `@credential_name = 'job_credential'`.
Copy file name to clipboardExpand all lines: azure-sql/database/elastic-jobs-tutorial.md
+26-6Lines changed: 26 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,7 +4,7 @@ description: "Learn how to create, configure, and manage elastic jobs to run Tra
4
4
author: WilliamDAssafMSFT
5
5
ms.author: wiassaf
6
6
ms.reviewer: srinia
7
-
ms.date: 11/02/2023
7
+
ms.date: 11/14/2023
8
8
ms.service: sql-database
9
9
ms.subservice: elastic-jobs
10
10
ms.topic: how-to
@@ -21,7 +21,7 @@ This article provides the steps required to create, configure, and manage elasti
21
21
22
22
## Create and configure the elastic job agent
23
23
24
-
1. Create or identify an empty S1 or higher Azure SQL Database. This database should be in the same server as the job agent. This database is used as the *job database* during elastic job agent creation. You can [create a single database](single-database-create-quickstart.md?view=azuresql-db&preserve-view=true) via the Azure portal, Azure CLI, Azure CLI (sql up), or PowerShell.
24
+
1. Create or identify an empty S1 or higher Azure SQL Database, using the DTU purchase model. This database should be in the same server as the job agent. This database is used as the *job database* during elastic job agent creation. You can [create a single database](single-database-create-quickstart.md?view=azuresql-db&preserve-view=true) via the Azure portal, Azure CLI, Azure CLI (sql up), or PowerShell.
25
25
1. Create an **elastic job agent** in the Azure portal or with [PowerShell](elastic-jobs-powershell-create.md#create-the-elastic-job-agent).
26
26
27
27
The instructions to create an elastic job agent in the Azure portal are as follows:
@@ -62,9 +62,18 @@ Use [Microsoft Entra (formerly Azure Active Directory)](authentication-aad-overv
62
62
-[A new UMI can be created](/azure/active-directory/managed-identities-azure-resources/how-manage-user-assigned-managed-identities) through the Azure portal, Azure CLI, PowerShell, Resource Manager, or REST API.
63
63
1. Assign the UMI to the created elastic job agent.
64
64
- It's recommended to assign a UMI when creating the elastic job agent, see the steps in [Create and configure the elastic job agent](#create-and-configure-the-elastic-job-agent). When creating a job agent in the Azure portal, in the **Identity** tab, assign to the elastic job agent.
65
-
- Currently in the Elastic Jobs preview, you cannot use PowerShell cmdlets to create or modify elastic job agents to use Microsoft Entra authentication with a UMI.
66
65
- To update an existing elastic job agent to use a UMI, on the Azure portal page for the **elastic job agent**, navigate to **Identity** under the **Security** menu in the resource menu. Select and assign the UMI to the elastic job agent.
67
-
- The [REST API can also be used to create or update the elastic job agent](/rest/api/sql/2021-02-01-preview/job-agents/create-or-update?tabs=HTTP). <!-- TODO update /2021-02-01/ when available -->
66
+
- When creating or updating an elastic job agent with the `New-AzSqlElasticJobAgent` or `Set-AzSqlElasticJobAgent` PowerShell cmdlets, use the parameters: `-IdentityType UserAssigned -IdentityID <identity resource path>`. For example:
67
+
```powershell
68
+
$parameters = @{
69
+
Name = '<job agent name>'
70
+
ResourceGroupName = '<Resource_Group_Name>'
71
+
IdentityType = 'UserAssigned'
72
+
IdentityID = '/subscriptions/fa58cf66-caaf-4ba9-875d-f1234/resourceGroups/<resource group name>/providers/Microsoft.ManagedIdentity/userAssignedIdentities/<UMI name here>'
73
+
}
74
+
Set-AzSqlElasticJobAgent @parameters
75
+
```
76
+
- The [REST API can also be used to create or update the elastic job agent](/rest/api/sql/job-agents/create-or-update).
68
77
1. Create a target group and add targets for the jobs. [Define the target group and targets (the databases you want to run the job against) using PowerShell](elastic-jobs-powershell-create.md#define-target-servers-and-databases) or [define the target group and targets using T-SQL](elastic-jobs-tsql-create-manage.md#define-target-servers-and-databases).
69
78
1. In each of the target server(s)/database(s), [create a contained user mapped to the UMI](#use-microsoft-entra-authentication-with-a-user-assigned-managed-identity-umi).
70
79
1. In the output database, create and assign permissions to the UMI job user. Connect to the output database and run the following example script for a user named `jobuserUMI`:
@@ -166,7 +175,7 @@ To proceed with the Azure portal:
166
175
167
176
By default, job agents are created at JA100, allowing up to 100 elastic job executions concurrently. Initiating a service level change is an asynchronous operation and the new service level will be made available after a short provisioning delay.
168
177
169
-
If you need more than 100 concurrent executions of elastic job agents, higher service levels are available, see [Concurrent capacity tiers](elastic-jobs-overview.md#concurrent-capacity-tiers). You can currently change the service level of a job agent via the Azure portal or REST API.
178
+
If you need more than 100 concurrent executions of elastic job agents, higher service levels are available, see [Concurrent capacity tiers](elastic-jobs-overview.md#concurrent-capacity-tiers). You can currently change the service level of a job agent via the Azure portal, PowerShell, or REST API.
170
179
171
180
Exceeding the service level with concurrent jobs will create queuing delays before jobs start in excess of the [service level's concurrent jobs limit](elastic-jobs-overview.md#concurrent-capacity-tiers).
172
181
@@ -178,10 +187,21 @@ Exceeding the service level with concurrent jobs will create queuing delays befo
178
187
1. Review the cost card.
179
188
1. Select **Update**.
180
189
190
+
### Scale the elastic job agent by using PowerShell
191
+
192
+
The optional `-ServiceObjective` parameter for `Set-AzSqlElasticJobAgent` can be used to specify a new service objective. For example:
193
+
```powershell
194
+
$parameters = @{
195
+
Name = '<job agent name>'
196
+
ResourceGroupName = '<Resource_Group_Name>'
197
+
ServiceObjective = 'JA200'
198
+
}
199
+
Set-AzSqlElasticJobAgent @parameters
200
+
```
181
201
182
202
### Scale the elastic job agent by using REST API
183
203
184
-
You can use the [Job agent REST API](/rest/api/sql/2021-02-01-preview/job-agents#operations) <!-- update 2021-02-01-preview --> to scale a job agent. For example:
204
+
You can use the [Job agent REST API](/rest/api/sql/job-agents) to scale a job agent. For example:
description: "The jobs.job_executions system view contains information about Azure Elastic job execution history."
4
4
author: WilliamDAssafMSFT
5
5
ms.author: wiassaf
6
-
ms.date: 11/03/2023
6
+
ms.date: 11/13/2023
7
7
ms.service: sql-database
8
8
ms.subservice: system-objects
9
9
ms.topic: "reference"
@@ -66,6 +66,9 @@ The following table lists the possible job execution states in `lifecycle`:
66
66
67
67
Members of the *jobs_reader* role can SELECT from this view. For more information, see [Elastic jobs in Azure SQL Database (preview)](/azure/azure-sql/database/elastic-jobs-overview?view=azuresql-db&preserve-view=true#elastic-job-database-permissions).
68
68
69
+
> [!CAUTION]
70
+
> You should not update internal catalog views in the *job database*. Manually changing these catalog views can corrupt the *job database* and cause failure. These views are for read-only querying only. You can use the stored procedures on your *job database*.
71
+
69
72
## Remarks
70
73
71
74
All times in elastic jobs are in the UTC time zone.
description: "The jobs.job_versions system view contains job version history in Azure Elastic jobs."
4
4
author: WilliamDAssafMSFT
5
5
ms.author: wiassaf
6
-
ms.date: 10/30/2023
6
+
ms.date: 11/13/2023
7
7
ms.service: sql-database
8
8
ms.subservice: system-objects
9
9
ms.topic: "reference"
@@ -33,6 +33,9 @@ Contains version history about jobs in the [Azure Elastic Jobs service for Azure
33
33
34
34
Members of the *jobs_reader* role can SELECT from this view. For more information, see [Elastic jobs in Azure SQL Database (preview)](/azure/azure-sql/database/elastic-jobs-overview?view=azuresql-db&preserve-view=true#elastic-job-database-permissions).
35
35
36
+
> [!CAUTION]
37
+
> You should not update internal catalog views in the *job database*. Manually changing these catalog views can corrupt the *job database* and cause failure. These views are for read-only querying only. You can use the stored procedures on your *job database*.
38
+
36
39
## Remarks
37
40
38
41
All times in elastic jobs are in the UTC time zone.
0 commit comments