Obtenir le contenu d'un brouillon de runbook
Le Get content of draft runbook opération retourne le contenu d'un projet de procédure opérationnelle.
Utilisez le Obtention du contenu d'un runbook publié opération obtenir le contenu d'un runbook publié.
Demande
Pour spécifier la requête, remplacez < id d'abonnement > par votre ID d'abonnement < cloud-service-name > avec le nom du service cloud à utiliser pour la demande, < automation-account-name > avec le nom du compte à utiliser pour effectuer la demande et < nom du runbook > par le nom de la procédure opérationnelle brouillon pour obtenir du contenu d'automation. Incluez les paramètres d'URI nécessaires.
Méthode |
URI de demande |
---|---|
GET |
https://management.core.windows.net/<subscriptionId>/cloudServices/<cloud-service-name>/resources/automation/~/automationAccounts/<automation-account-name>/runbooks/<runbook-name>/draft/content?api-version=2014-12-08 |
Paramètres URI
Paramètre |
Description |
---|---|
api-version |
Obligatoire. Doit avoir la valeur 2014-12-08. |
En-têtes de demande
L'en-tête de demande dans le tableau suivant est nécessaire.
En-tête de demande |
Description |
---|---|
x-ms-version |
Spécifie la version de l'opération. La valeur 2013-06-01 ou une version ultérieure. |
Corps de la demande
Aucune
Réponse
Code d'état
Une opération réussie renvoie la valeur 200 (OK). Pour plus d'informations sur les codes d'erreur courants, consultez définitions de Code d'état HTTP/1.1.
En-têtes de réponse
En-tête de demande |
Description |
---|---|
x-ms-request-id |
Identificateur unique de l'opération en cours. |
Corps de la réponse
Le runbook est fourni après les en-têtes de réponse avec le type de contenu text/powershell, comme illustré dans l'exemple suivant :
HTTP/1.1 200 OK Cache-Control: no-cache Pragma: no-cache Content-Length: 5286 Content-Type: text/powershell Expires: -1 ETag: "635657056882600000" Vary: Accept-Encoding Server: 1.0.6198.202 (rd_rdfe_stable.150307-1902) Microsoft-HTTPAPI/2.0 Strict-Transport-Security: max-age=31536000; includeSubDomains,max-age=31536000; includeSubDomains X-AspNet-Version: 4.0.30319 X-Powered-By: ASP.NET,ASP.NET x-ms-request-id: 5b054afd3bc02ce1925af4c643a9af8c Date: Mon, 27 Apr 2015 04:39:44 GMT <# .SYNOPSIS Copies a file to an Azure VM. .DESCRIPTION This runbook copies a local file to an Azure virtual machine. Connect-AzureVM must be imported and published in order for this runbook to work. The Connect-AzureVM runbook sets up the connection to the virtual machine where the local file will be copied to. When using this runbook, be aware that the memory and disk space size of the processes running your runbooks is limited. Because of this, we recommened only using runbooks to transfer small files. All Automation Integration Module assets in your account are loaded into your processes, so be aware that the more Integration Modules you have in your system, the smaller the free space in your processes will be. To ensure maximum disk space in your processes, make sure to clean up any local files a runbook transfers or creates in the process before the runbook completes. .PARAMETER AzureSubscriptionName Name of the Azure subscription to connect to .PARAMETER AzureOrgIdCredential A credential containing an Org Id username / password with access to this Azure subscription. If invoking this runbook inline from within another runbook, pass a PSCredential for this parameter. If starting this runbook using Start-AzureAutomationRunbook, or via the Azure portal UI, pass as a string the name of an Azure Automation PSCredential asset instead. Azure Automation will automatically grab the asset with that name and pass it into the runbook. .PARAMETER ServiceName Name of the cloud service where the VM is located. .PARAMETER VMName Name of the virtual machine that you want to connect to. .PARAMETER VMCredentialName Name of a PowerShell credential asset that is stored in the Automation service. This credential should have access to the virtual machine. .PARAMETER LocalPath The local path to the item to copy to the Azure virtual machine. .PARAMETER RemotePath The remote path on the Azure virtual machine where the item should be copied to. .EXAMPLE Copy-ItemToAzureVM -AzureSubscriptionName "Visual Studio Ultimate with MSDN" -ServiceName "myService" -VMName "myVM" -VMCredentialName "myVMCred" -LocalPath ".\myFile.txt" -RemotePath "C:\Users\username\myFileCopy.txt" -AzureOrgIdCredential $cred .NOTES AUTHOR: System Center Automation Team LASTEDIT: Apr 26, 2015 #> workflow Copy-ItemToAzureVM { param ( [parameter(Mandatory=$true)] [String] $AzureSubscriptionName, [parameter(Mandatory=$true)] [PSCredential] $AzureOrgIdCredential, [parameter(Mandatory=$true)] [String] $ServiceName, [parameter(Mandatory=$true)] [String] $VMName, [parameter(Mandatory=$true)] [String] $VMCredentialName, [parameter(Mandatory=$true)] [String] $LocalPath, [parameter(Mandatory=$true)] [String] $RemotePath ) # Get credentials to Azure VM $Credential = Get-AutomationPSCredential -Name $VMCredentialName if ($Credential -eq $null) { throw "Could not retrieve '$VMCredentialName' credential asset. Check that you created this asset in the Automation service." } # Set up the Azure VM connection by calling the Connect-AzureVM runbook. You should call this runbook after # every CheckPoint-WorkFlow in your runbook to ensure that the connection to the Azure VM is restablished if this runbook # gets interrupted and starts from the last checkpoint. $Uri = Connect-AzureVM -AzureSubscriptionName $AzureSubscriptionName -AzureOrgIdCredential $AzureOrgIdCredential –ServiceName $ServiceName –VMName $VMName # Store the file contents on the Azure VM InlineScript { $ConfigurationName = "HighDataLimits" # Enable larger data to be sent Invoke-Command -ScriptBlock { $ConfigurationName = $args[0] $Session = Get-PSSessionConfiguration -Name $ConfigurationName if(!$Session) { Write-Verbose "Large data sending is not allowed. Creating PSSessionConfiguration $ConfigurationName" Register-PSSessionConfiguration -Name $ConfigurationName -MaximumReceivedDataSizePerCommandMB 500 -MaximumReceivedObjectSizeMB 500 -Force | Out-Null } } -ArgumentList $ConfigurationName -ConnectionUri $Using:Uri -Credential $Using:Credential -ErrorAction SilentlyContinue # Get the file contents locally $Content = Get-Content –Path $Using:LocalPath –Encoding Byte Write-Verbose ("Retrieved local content from $Using:LocalPath") Invoke-Command -ScriptBlock { param($Content, $RemotePath) $Content | Set-Content –Path $RemotePath -Encoding Byte } -ArgumentList $Content, $Using:RemotePath -ConnectionUri $Using:Uri -Credential $Using:Credential -ConfigurationName $ConfigurationName Write-Verbose ("Wrote content from $Using:LocalPath to $Using:VMName at $Using:RemotePath") } }