Runbook Draft - Replace Content

Replaces the runbook draft content.

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

URI Parameters

Name In Required Type Description
subscriptionId
path True
  • string

Gets subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call.

resourceGroupName
path True
  • string

Name of an Azure Resource group.

Regex pattern: ^[-\w\._]+$

automationAccountName
path True
  • string

The name of the automation account.

runbookName
path True
  • string

The runbook name.

api-version
query True
  • string

Client Api Version.

Request Body

Media Types: "text/powershell"

Name Required Type Description
runbookContent
  • object

Responses

Name Type Description
200 OK
  • file

OK

202 Accepted

Accepted and the operation will complete asynchronously.

Headers

  • location: string
Other Status Codes

Automation error response describing why the operation failed.

Examples

Create or update runbook draft

Sample Request

PUT https://management.azure.com/subscriptions/subid/resourceGroups/rg/providers/Microsoft.Automation/automationAccounts/ContoseAutomationAccount/runbooks/Get-AzureVMTutorial/draft/content?api-version=2015-10-31
"<#\r\n .description\r\n="" an="" example="" runbook="" which="" prints="" out="" the="" first10="" azure="" vms="" in="" your="" subscription="" (ordered="" alphabetically).\r\n="" for="" more="" information="" about="" how="" this="" runbook="" authenticates="" to="" your="" azure="" subscription,="" see="" our="" documentation="" here:="" http:="" aka.ms/fxu3mn\r\n\r\n="" .notes\r\n="" author:="" azure="" automation="" team\r\n="" lastedit:="" mar27,\r\n="" 2015\r\n="" #="">\r\n    workflow Get-AzureVMTutorial{\r\n        #The name of the Automation Credential Asset this runbook will use to authenticate to Azure.\r\n        $CredentialAssetName = 'DefaultAzureCredential'\r\n\r\n        #Get the credential with the above name from the Automation Asset store\r\n        $Cred = Get-AutomationPSCredential -Name $CredentialAssetName\r\n        if(!$Cred){\r\n            Throw\"Could not find an Automation Credential Asset named '${CredentialAssetName}'. Make sure you have created one in this Automation Account.\"\r\n                }\r\n\r\n        #Connect to your Azure Account\r\n        $Account = Add-AzureAccount -Credential $Cred\r\n        if(!$Account){\r\n            Throw\"Could not authenticate to Azure using the credential asset '${CredentialAssetName}'. Make sure the user name and password are correct.\"\r\n                }\r\n\r\n        #TODO (optional): pick the right subscription to use. Without this line, the default subscription for your Azure Account will be used.\r\n        #Select-AzureSubscription -SubscriptionName\"TODO: your Azure subscription name here\"\r\n        \r\n        #Get all the VMs you have in your Azure subscription\r\n        $VMs = Get-AzureVM\r\n\r\n        #Print out up to10 of those VMs\r\n        if(!$VMs){\r\n            Write-Output\"No VMs were found in your subscription.\"\r\n                } else{\r\n            Write-Output $VMs[0..9\r\n                    ]\r\n                }\r\n            }"

Sample Response

Location: https://management.azure.com/subscriptions/subid/resourcegroups/rg/providers/Microsoft.Automation/automationAccounts/ContoseAutomationAccount/runbooks/Get-AzureVMTutorial/draft/content/operationResults/9bd70be2-cf73-49b4-9467-5261d48c2b3d?api-version=2015-10-31

Definitions

ErrorResponse

Error response of an operation failure

Name Type Description
code
  • string

Error code

message
  • string

Error message indicating why the operation failed.