Runbook - Create Or Update

Create the runbook identified by runbook name.

PUT https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}?api-version=2024-10-23

URI Parameters

Name In Required Type Description
automationAccountName
path True

string

The name of the automation account.

resourceGroupName
path True

string

minLength: 1
maxLength: 90

The name of the resource group. The name is case insensitive.

runbookName
path True

string

pattern: ^[a-zA-Z][a-zA-Z-_0-9]*$

The runbook name.

subscriptionId
path True

string (uuid)

The ID of the target subscription. The value must be an UUID.

api-version
query True

string

minLength: 1

The API version to use for this operation.

Request Body

Name Required Type Description
properties.runbookType True

RunbookTypeEnum

Gets or sets the type of the runbook.

location

string

Gets or sets the location of the resource.

name

string

Gets or sets the name of the resource.

properties.description

string

Gets or sets the description of the runbook.

properties.draft

RunbookDraft

Gets or sets the draft runbook properties.

properties.logActivityTrace

integer (int32)

Gets or sets the activity-level tracing options of the runbook.

properties.logProgress

boolean

Gets or sets progress log option.

properties.logVerbose

boolean

Gets or sets verbose log option.

properties.publishContentLink

ContentLink

Gets or sets the published runbook content link.

properties.runtimeEnvironment

string

Environment of the runbook.

tags

object

Gets or sets the tags attached to the resource.

Responses

Name Type Description
200 OK

Runbook

Resource 'Runbook' update operation succeeded

201 Created

Runbook

Resource 'Runbook' create operation succeeded

Other Status Codes

ErrorResponse

An unexpected error response.

Security

azure_auth

Azure Active Directory OAuth2 Flow.

Type: oauth2
Flow: implicit
Authorization URL: https://login.microsoftonline.com/common/oauth2/authorize

Scopes

Name Description
user_impersonation impersonate your user account

Examples

Create or update runbook and publish it
Create runbook as draft

Create or update runbook and publish it

Sample request

PUT https://management.azure.com/subscriptions/aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee/resourceGroups/rg/providers/Microsoft.Automation/automationAccounts/ContoseAutomationAccount/runbooks/Get-AzureVMTutorial?api-version=2024-10-23

{
  "name": "Get-AzureVMTutorial",
  "location": "East US 2",
  "properties": {
    "description": "Description of the Runbook",
    "logActivityTrace": 1,
    "logProgress": true,
    "logVerbose": false,
    "publishContentLink": {
      "contentHash": {
        "algorithm": "SHA256",
        "value": "115775B8FF2BE672D8A946BD0B489918C724DDE15A440373CA54461D53010A80"
      },
      "uri": "https://raw.githubusercontent.com/Azure/azure-quickstart-templates/master/101-automation-runbook-getvms/Runbooks/Get-AzureVMTutorial.ps1"
    },
    "runbookType": "PowerShell",
    "runtimeEnvironment": "environmentName"
  },
  "tags": {
    "tag01": "value01",
    "tag02": "value02"
  }
}

Sample response

{
  "name": "Get-AzureVMTutorial",
  "type": "Microsoft.Automation/AutomationAccounts/Runbooks",
  "etag": "\"636263318866000000\"",
  "id": "/subscriptions/aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee/resourceGroups/rg/providers/Microsoft.Automation/automationAccounts/ContoseAutomationAccount/runbooks/Get-AzureVMTutorial",
  "location": "East US 2",
  "properties": {
    "description": "Description of the Runbook",
    "creationTime": "2017-03-28T21:04:43.66+00:00",
    "jobCount": 0,
    "lastModifiedBy": "myEmaild@microsoft.com",
    "lastModifiedTime": "2017-03-28T21:04:46.6+00:00",
    "logActivityTrace": 1,
    "logProgress": true,
    "logVerbose": true,
    "outputTypes": [],
    "parameters": {},
    "provisioningState": "Succeeded",
    "runbookType": "PowerShellWorkflow",
    "runtimeEnvironment": "environmentName",
    "state": "Published"
  },
  "tags": {
    "tag01": "value01",
    "tag02": "value02"
  }
}
{
  "name": "Get-AzureVMTutorial",
  "type": "Microsoft.Automation/AutomationAccounts/Runbooks",
  "etag": "\"636263318837230000\"",
  "id": "/subscriptions/aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee/resourceGroups/rg/providers/Microsoft.Automation/automationAccounts/ContoseAutomationAccount/runbooks/Get-AzureVMTutorial",
  "location": "East US 2",
  "properties": {
    "description": "Description of the Runbook",
    "creationTime": "2017-03-28T21:04:43.66+00:00",
    "jobCount": 0,
    "lastModifiedBy": "myEmaild@microsoft.com",
    "lastModifiedTime": "2017-03-28T21:04:43.723+00:00",
    "logActivityTrace": 1,
    "logProgress": true,
    "logVerbose": false,
    "outputTypes": [],
    "parameters": {},
    "provisioningState": "Succeeded",
    "runbookType": "PowerShell",
    "runtimeEnvironment": "environmentName",
    "state": "Published"
  },
  "tags": {
    "tag01": "value01",
    "tag02": "value02"
  }
}

Create runbook as draft

Sample request

PUT https://management.azure.com/subscriptions/aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee/resourceGroups/rg/providers/Microsoft.Automation/automationAccounts/ContoseAutomationAccount/runbooks/Get-AzureVMTutorial?api-version=2024-10-23

{
  "name": "Get-AzureVMTutorial",
  "location": "East US 2",
  "properties": {
    "description": "Description of the Runbook",
    "draft": {},
    "logProgress": false,
    "logVerbose": false,
    "runbookType": "PowerShell",
    "runtimeEnvironment": "environmentName"
  },
  "tags": {
    "tag01": "value01",
    "tag02": "value02"
  }
}

Sample response

{
  "name": "Get-AzureVMTutorial",
  "type": "Microsoft.Automation/AutomationAccounts/Runbooks",
  "etag": "\"636263318866000000\"",
  "id": "/subscriptions/aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee/resourceGroups/rg/providers/Microsoft.Automation/automationAccounts/ContoseAutomationAccount/runbooks/Get-AzureVMTutorial",
  "location": "East US 2",
  "properties": {
    "description": "Description of the Runbook",
    "creationTime": "2018-02-09T03:25:59.097+00:00",
    "jobCount": 0,
    "lastModifiedTime": "2018-02-09T03:25:59.097+00:00",
    "logActivityTrace": 0,
    "logProgress": false,
    "logVerbose": false,
    "parameters": {},
    "provisioningState": "Succeeded",
    "runbookType": "PowerShell",
    "runtimeEnvironment": "environmentName",
    "state": "New"
  },
  "tags": {
    "tag01": "value01",
    "tag02": "value02"
  }
}
{
  "name": "Get-AzureVMTutorial",
  "type": "Microsoft.Automation/AutomationAccounts/Runbooks",
  "etag": "\"636263318837230000\"",
  "id": "/subscriptions/aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee/resourceGroups/rg/providers/Microsoft.Automation/automationAccounts/ContoseAutomationAccount/runbooks/Get-AzureVMTutorial",
  "location": "East US 2",
  "properties": {
    "description": "Description of the Runbook",
    "creationTime": "2018-02-09T03:25:59.097+00:00",
    "jobCount": 0,
    "lastModifiedTime": "2018-02-09T03:25:59.097+00:00",
    "logActivityTrace": 0,
    "logProgress": false,
    "logVerbose": false,
    "outputTypes": [],
    "parameters": {},
    "provisioningState": "Succeeded",
    "runbookType": "PowerShell",
    "runtimeEnvironment": "environmentName",
    "state": "New"
  },
  "tags": {
    "tag01": "value01",
    "tag02": "value02"
  }
}

Definitions

Name Description
ContentHash

Definition of the runbook property type.

ContentLink

Definition of the content link.

createdByType

The type of identity that created the resource.

ErrorAdditionalInfo

The resource management error additional info.

ErrorDetail

The error detail.

ErrorResponse

Error response

Runbook

Definition of the runbook type.

RunbookCreateOrUpdateParameters

The parameters supplied to the create or update runbook operation.

RunbookDraft
RunbookParameter

Definition of the runbook parameter type.

RunbookState

Gets or sets the state of the runbook.

RunbookTypeEnum

Gets or sets the type of the runbook.

systemData

Metadata pertaining to creation and last modification of the resource.

ContentHash

Definition of the runbook property type.

Name Type Description
algorithm

string

Gets or sets the content hash algorithm used to hash the content.

value

string

Gets or sets expected hash value of the content.

Definition of the content link.

Name Type Description
contentHash

ContentHash

Gets or sets the hash.

uri

string

Gets or sets the uri of content.

version

string

Gets or sets the version of the content.

createdByType

The type of identity that created the resource.

Value Description
User
Application
ManagedIdentity
Key

ErrorAdditionalInfo

The resource management error additional info.

Name Type Description
info

object

The additional info.

type

string

The additional info type.

ErrorDetail

The error detail.

Name Type Description
additionalInfo

ErrorAdditionalInfo[]

The error additional info.

code

string

The error code.

details

ErrorDetail[]

The error details.

message

string

The error message.

target

string

The error target.

ErrorResponse

Error response

Name Type Description
error

ErrorDetail

The error object.

Runbook

Definition of the runbook type.

Name Type Description
etag

string

Gets or sets the etag of the resource.

id

string (arm-id)

Fully qualified resource ID for the resource. E.g. "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}"

location

string

The geo-location where the resource lives

name

string

The name of the resource

properties.creationTime

string (date-time)

Gets or sets the creation time.

properties.description

string

Gets or sets the description.

properties.draft

RunbookDraft

Gets or sets the draft runbook properties.

properties.jobCount

integer (int32)

Gets or sets the job count of the runbook.

properties.lastModifiedBy

string

Gets or sets the last modified by.

properties.lastModifiedTime

string (date-time)

Gets or sets the last modified time.

properties.logActivityTrace

integer (int32)

Gets or sets the option to log activity trace of the runbook.

properties.logProgress

boolean

Gets or sets progress log option.

properties.logVerbose

boolean

Gets or sets verbose log option.

properties.outputTypes

string[]

Gets or sets the runbook output types.

properties.parameters

<string,  RunbookParameter>

Gets or sets the runbook parameters.

properties.provisioningState enum:

Succeeded

Gets or sets the provisioning state of the runbook.

properties.publishContentLink

ContentLink

Gets or sets the published runbook content link.

properties.runbookType

RunbookTypeEnum

Gets or sets the type of the runbook.

properties.runtimeEnvironment

string

Runtime Environment of the runbook execution.

properties.state

RunbookState

Gets or sets the state of the runbook.

systemData

systemData

Azure Resource Manager metadata containing createdBy and modifiedBy information.

tags

object

Resource tags.

type

string

The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts"

RunbookCreateOrUpdateParameters

The parameters supplied to the create or update runbook operation.

Name Type Description
location

string

Gets or sets the location of the resource.

name

string

Gets or sets the name of the resource.

properties.description

string

Gets or sets the description of the runbook.

properties.draft

RunbookDraft

Gets or sets the draft runbook properties.

properties.logActivityTrace

integer (int32)

Gets or sets the activity-level tracing options of the runbook.

properties.logProgress

boolean

Gets or sets progress log option.

properties.logVerbose

boolean

Gets or sets verbose log option.

properties.publishContentLink

ContentLink

Gets or sets the published runbook content link.

properties.runbookType

RunbookTypeEnum

Gets or sets the type of the runbook.

properties.runtimeEnvironment

string

Environment of the runbook.

tags

object

Gets or sets the tags attached to the resource.

RunbookDraft

Name Type Description
creationTime

string (date-time)

Gets or sets the creation time of the runbook draft.

draftContentLink

ContentLink

Gets or sets the draft runbook content link.

inEdit

boolean

Gets or sets whether runbook is in edit mode.

lastModifiedTime

string (date-time)

Gets or sets the last modified time of the runbook draft.

outputTypes

string[]

Gets or sets the runbook output types.

parameters

<string,  RunbookParameter>

Gets or sets the runbook draft parameters.

RunbookParameter

Definition of the runbook parameter type.

Name Type Description
defaultValue

string

Gets or sets the default value of parameter.

isMandatory

boolean

Gets or sets a Boolean value to indicate whether the parameter is mandatory or not.

position

integer (int32)

Get or sets the position of the parameter.

type

string

Gets or sets the type of the parameter.

RunbookState

Gets or sets the state of the runbook.

Value Description
New

New

Edit

Edit

Published

Published

RunbookTypeEnum

Gets or sets the type of the runbook.

Value Description
Script

Script

Graph

Graph

PowerShellWorkflow

PowerShellWorkflow

PowerShell

PowerShell

GraphPowerShellWorkflow

GraphPowerShellWorkflow

GraphPowerShell

GraphPowerShell

Python2

Python2

Python3

Python3

Python

Python

PowerShell72

PowerShell72

systemData

Metadata pertaining to creation and last modification of the resource.

Name Type Description
createdAt

string (date-time)

The timestamp of resource creation (UTC).

createdBy

string

The identity that created the resource.

createdByType

createdByType

The type of identity that created the resource.

lastModifiedAt

string (date-time)

The timestamp of resource last modification (UTC)

lastModifiedBy

string

The identity that last modified the resource.

lastModifiedByType

createdByType

The type of identity that last modified the resource.