Runbook - Get Content

Recuperare il contenuto del runbook identificato dal nome del runbook.

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

Parametri dell'URI

Nome In Necessario Tipo Descrizione
automationAccountName
path True

string

Nome dell'account di automazione.

resourceGroupName
path True

string

Nome di un gruppo di risorse di Azure.

Criterio di espressione regolare: ^[-\w\._]+$

runbookName
path True

string

Nome del runbook.

Criterio di espressione regolare: ^[a-zA-Z][a-zA-Z-_0-9]*$

subscriptionId
path True

string

Ottiene le credenziali di sottoscrizione che consentono di identificare in modo univoco la sottoscrizione Microsoft Azure. L'ID sottoscrizione fa parte dell'URI per ogni chiamata di servizio.

api-version
query True

string

Versione api client.

Risposte

Nome Tipo Descrizione
200 OK

file

OK

Media Types: "text/powershell"

Other Status Codes

ErrorResponse

Risposta di errore di automazione che descrive il motivo per cui l'operazione non è riuscita.

Media Types: "text/powershell"

Sicurezza

azure_auth

Flusso OAuth2 di Azure Active Directory

Tipo: oauth2
Flow: implicit
URL di autorizzazione: https://login.microsoftonline.com/common/oauth2/authorize

Ambiti

Nome Descrizione
user_impersonation rappresentare l'account utente

Esempio

Get runbook content

Esempio di richiesta

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

Risposta di esempio

Content-Type: text/powershell
"<#\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\nworkflow 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            }"

Definizioni

ErrorResponse

Risposta di errore di un errore dell'operazione

Nome Tipo Descrizione
code

string

Codice di errore

message

string

Messaggio di errore che indica il motivo per cui l'operazione non è riuscita.