Partager via


Runbook Draft - Replace Content

Remplace le contenu brouillon du runbook.

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

Paramètres URI

Nom Dans Obligatoire Type Description
automationAccountName
path True

string

Nom du compte Automation.

resourceGroupName
path True

string

Nom d’un groupe de ressources Azure.

Modèle d’expression régulière: ^[-\w\._]+$

runbookName
path True

string

Nom du runbook.

Modèle d’expression régulière: ^[a-zA-Z][a-zA-Z-_0-9]*$

subscriptionId
path True

string

Obtient les informations d'identification d'abonnement qui identifient l'abonnement Microsoft Azure de manière unique. L’ID d’abonnement fait partie de l’URI pour chaque appel de service.

api-version
query True

string

Version de l’API cliente.

Corps de la demande

Media Types: "text/powershell"

Nom Type Description
runbookContent

object

Contenu brouillon de runbook.

Réponses

Nom Type Description
200 OK

file

Ok

202 Accepted

Accepté et l’opération se termine de manière asynchrone.

En-têtes

location: string

Other Status Codes

ErrorResponse

Réponse d’erreur Automation décrivant la raison de l’échec de l’opération.

Sécurité

azure_auth

Flux OAuth2 Azure Active Directory

Type: oauth2
Flux: implicit
URL d’autorisation: https://login.microsoftonline.com/common/oauth2/authorize

Étendues

Nom Description
user_impersonation Emprunter l’identité de votre compte d’utilisateur

Exemples

Create or update runbook draft

Exemple de requête

PUT https://management.azure.com/subscriptions/subid/resourceGroups/rg/providers/Microsoft.Automation/automationAccounts/ContoseAutomationAccount/runbooks/Get-AzureVMTutorial/draft/content?api-version=2023-11-01

"<#\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            }"

Exemple de réponse

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=2019-06-01
{}

Définitions

ErrorResponse

Réponse d’erreur d’un échec d’opération

Nom Type Description
code

string

Code d'erreur

message

string

Message d’erreur indiquant la raison de l’échec de l’opération.