Job Steps - Create Or Update

Creates or updates a job step. This will implicitly create a new job version.

PUT https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}/steps/{stepName}?api-version=2021-11-01

URI Parameters

Name In Required Type Description
jobAgentName
path True

string

The name of the job agent.

jobName
path True

string

The name of the job.

resourceGroupName
path True

string

The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal.

serverName
path True

string

The name of the server.

stepName
path True

string

The name of the job step.

subscriptionId
path True

string

The subscription ID that identifies an Azure subscription.

api-version
query True

string

The API version to use for the request.

Request Body

Name Required Type Description
properties.action True

JobStepAction

The action payload of the job step.

properties.credential True

string

The resource ID of the job credential that will be used to connect to the targets.

properties.targetGroup True

string

The resource ID of the target group that the job step will be executed on.

properties.executionOptions

JobStepExecutionOptions

Execution options for the job step.

properties.output

JobStepOutput

Output destination properties of the job step.

properties.stepId

integer

The job step's index within the job. If not specified when creating the job step, it will be created as the last step. If not specified when updating the job step, the step id is not modified.

Responses

Name Type Description
200 OK

JobStep

Successfully updated the job step.

201 Created

JobStep

Successfully added the job step.

Other Status Codes

*** Error Responses: ***

  • 400 JobStepIdMismatch - Step Id in the specified Job Step URI does not match step id in provided Job Step Resource.

  • 400 InvalidResourceRequestBody - The resource or resource properties in the request body is empty or invalid.

  • 400 InvalidResourceId - Invalid resource identifier.

  • 400 MismatchingSubscriptionWithUrl - The provided subscription did not match the subscription in the Url.

  • 400 MismatchingResourceGroupNameWithUrl - The provided resource group name did not match the name in the Url.

  • 400 MismatchingServerNameWithUrl - The provided server name did not match the name in the Url.

  • 400 MismatchingJobAccountNameWithUrl - The provided job account name did not match the name in the Url.

  • 400 ElasticJobsOperationFailed - Elastic jobs management operation failed.

  • 400 ElasticJobsOperationFailed - Elastic jobs management operation failed.

  • 404 JobAgentNotFound - Specified job agent does not exist in the specified logical server.

  • 404 ResourceNotFound - The requested resource was not found.

  • 404 SubscriptionDoesNotHaveServer - The requested server was not found

  • 404 ServerNotInSubscriptionResourceGroup - Specified server does not exist in the specified resource group and subscription.

Examples

Create or update a job step with all properties specified.
Create or update a job step with minimal properties specified.

Create or update a job step with all properties specified.

Sample request

PUT https://management.azure.com/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/group1/providers/Microsoft.Sql/servers/server1/jobAgents/agent1/jobs/job1/steps/step1?api-version=2021-11-01

{
  "properties": {
    "stepId": 1,
    "targetGroup": "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/group1/providers/Microsoft.Sql/servers/server1/jobAgents/agent1/targetGroups/targetGroup1",
    "credential": "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/group1/providers/Microsoft.Sql/servers/server1/jobAgents/agent1/credentials/cred1",
    "action": {
      "type": "TSql",
      "source": "Inline",
      "value": "select 2"
    },
    "output": {
      "type": "SqlDatabase",
      "subscriptionId": "3501b905-a848-4b5d-96e8-b253f62d735a",
      "resourceGroupName": "group3",
      "serverName": "server3",
      "databaseName": "database3",
      "schemaName": "myschema1234",
      "tableName": "mytable5678",
      "credential": "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/group1/providers/Microsoft.Sql/servers/server1/jobAgents/agent1/credentials/cred0"
    },
    "executionOptions": {
      "timeoutSeconds": 1234,
      "retryAttempts": 42,
      "initialRetryIntervalSeconds": 11,
      "maximumRetryIntervalSeconds": 222,
      "retryIntervalBackoffMultiplier": 3
    }
  }
}

Sample response

{
  "properties": {
    "stepId": 1,
    "targetGroup": "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/group1/providers/Microsoft.Sql/servers/server1/jobAgents/agent1/targetGroups/targetGroup1",
    "credential": "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/group1/providers/Microsoft.Sql/servers/server1/jobAgents/agent1/credentials/cred1",
    "action": {
      "type": "TSql",
      "source": "Inline",
      "value": "select 2"
    },
    "output": {
      "type": "SqlDatabase",
      "subscriptionId": "3501b905-a848-4b5d-96e8-b253f62d735a",
      "resourceGroupName": "group3",
      "serverName": "server3",
      "databaseName": "database3",
      "schemaName": "myschema1234",
      "tableName": "mytable5678",
      "credential": "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/group1/providers/Microsoft.Sql/servers/server1/jobAgents/agent1/credentials/cred0"
    },
    "executionOptions": {
      "timeoutSeconds": 1234,
      "retryAttempts": 42,
      "initialRetryIntervalSeconds": 11,
      "maximumRetryIntervalSeconds": 222,
      "retryIntervalBackoffMultiplier": 3
    }
  },
  "id": "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/group1/providers/Microsoft.Sql/servers/server1/jobAgents/agent1/jobs/job1/steps/step1",
  "name": "step1",
  "type": "Microsoft.Sql/servers/jobAgents/jobs/steps"
}
{
  "properties": {
    "stepId": 1,
    "targetGroup": "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/group1/providers/Microsoft.Sql/servers/server1/jobAgents/agent1/targetGroups/targetGroup1",
    "credential": "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/group1/providers/Microsoft.Sql/servers/server1/jobAgents/agent1/credentials/cred1",
    "action": {
      "type": "TSql",
      "source": "Inline",
      "value": "select 2"
    },
    "output": {
      "type": "SqlDatabase",
      "subscriptionId": "3501b905-a848-4b5d-96e8-b253f62d735a",
      "resourceGroupName": "group3",
      "serverName": "server3",
      "databaseName": "database3",
      "schemaName": "myschema1234",
      "tableName": "mytable5678",
      "credential": "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/group1/providers/Microsoft.Sql/servers/server1/jobAgents/agent1/credentials/cred0"
    },
    "executionOptions": {
      "timeoutSeconds": 1234,
      "retryAttempts": 42,
      "initialRetryIntervalSeconds": 11,
      "maximumRetryIntervalSeconds": 222,
      "retryIntervalBackoffMultiplier": 3
    }
  },
  "id": "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/group1/providers/Microsoft.Sql/servers/server1/jobAgents/agent1/jobs/job1/steps/step1",
  "name": "step1",
  "type": "Microsoft.Sql/servers/jobAgents/jobs/steps"
}

Create or update a job step with minimal properties specified.

Sample request

PUT https://management.azure.com/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/group1/providers/Microsoft.Sql/servers/server1/jobAgents/agent1/jobs/job1/steps/step1?api-version=2021-11-01

{
  "properties": {
    "targetGroup": "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/group1/providers/Microsoft.Sql/servers/server1/jobAgents/agent1/targetGroups/targetGroup0",
    "credential": "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/group1/providers/Microsoft.Sql/servers/server1/jobAgents/agent1/credentials/cred0",
    "action": {
      "value": "select 1"
    }
  }
}

Sample response

{
  "properties": {
    "stepId": 1,
    "targetGroup": "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/group1/providers/Microsoft.Sql/servers/server1/jobAgents/agent1/targetGroups/targetGroup0",
    "credential": "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/group1/providers/Microsoft.Sql/servers/server1/jobAgents/agent1/credentials/cred0",
    "action": {
      "type": "TSql",
      "source": "Inline",
      "value": "select 1"
    },
    "executionOptions": {
      "timeoutSeconds": 43200,
      "retryAttempts": 10,
      "initialRetryIntervalSeconds": 1,
      "maximumRetryIntervalSeconds": 120,
      "retryIntervalBackoffMultiplier": 2
    }
  },
  "id": "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/group1/providers/Microsoft.Sql/servers/server1/jobAgents/agent1/jobs/job1/steps/step1",
  "name": "step1",
  "type": "Microsoft.Sql/servers/jobAgents/jobs/steps"
}
{
  "properties": {
    "stepId": 1,
    "targetGroup": "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/group1/providers/Microsoft.Sql/servers/server1/jobAgents/agent1/targetGroups/targetGroup0",
    "credential": "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/group1/providers/Microsoft.Sql/servers/server1/jobAgents/agent1/credentials/cred0",
    "action": {
      "type": "TSql",
      "source": "Inline",
      "value": "select 1"
    },
    "executionOptions": {
      "timeoutSeconds": 43200,
      "retryAttempts": 10,
      "initialRetryIntervalSeconds": 1,
      "maximumRetryIntervalSeconds": 120,
      "retryIntervalBackoffMultiplier": 2
    }
  },
  "id": "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/group1/providers/Microsoft.Sql/servers/server1/jobAgents/agent1/jobs/job1/steps/step1",
  "name": "step1",
  "type": "Microsoft.Sql/servers/jobAgents/jobs/steps"
}

Definitions

Name Description
JobStep

A job step.

JobStepAction

The action to be executed by a job step.

JobStepActionSource

The source of the action to execute.

JobStepActionType

Type of action being executed by the job step.

JobStepExecutionOptions

The execution options of a job step.

JobStepOutput

The output configuration of a job step.

JobStepOutputType

The output destination type.

JobStep

A job step.

Name Type Description
id

string

Resource ID.

name

string

Resource name.

properties.action

JobStepAction

The action payload of the job step.

properties.credential

string

The resource ID of the job credential that will be used to connect to the targets.

properties.executionOptions

JobStepExecutionOptions

Execution options for the job step.

properties.output

JobStepOutput

Output destination properties of the job step.

properties.stepId

integer

The job step's index within the job. If not specified when creating the job step, it will be created as the last step. If not specified when updating the job step, the step id is not modified.

properties.targetGroup

string

The resource ID of the target group that the job step will be executed on.

type

string

Resource type.

JobStepAction

The action to be executed by a job step.

Name Type Default value Description
source

JobStepActionSource

Inline

The source of the action to execute.

type

JobStepActionType

TSql

Type of action being executed by the job step.

value

string

The action value, for example the text of the T-SQL script to execute.

JobStepActionSource

The source of the action to execute.

Name Type Description
Inline

string

JobStepActionType

Type of action being executed by the job step.

Name Type Description
TSql

string

JobStepExecutionOptions

The execution options of a job step.

Name Type Default value Description
initialRetryIntervalSeconds

integer

1

Initial delay between retries for job step execution.

maximumRetryIntervalSeconds

integer

120

The maximum amount of time to wait between retries for job step execution.

retryAttempts

integer

10

Maximum number of times the job step will be reattempted if the first attempt fails.

retryIntervalBackoffMultiplier

number

2

The backoff multiplier for the time between retries.

timeoutSeconds

integer

43200

Execution timeout for the job step.

JobStepOutput

The output configuration of a job step.

Name Type Default value Description
credential

string

The resource ID of the credential to use to connect to the output destination.

databaseName

string

The output destination database.

resourceGroupName

string

The output destination resource group.

schemaName

string

dbo

The output destination schema.

serverName

string

The output destination server name.

subscriptionId

string

The output destination subscription id.

tableName

string

The output destination table.

type

JobStepOutputType

SqlDatabase

The output destination type.

JobStepOutputType

The output destination type.

Name Type Description
SqlDatabase

string