你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn。
Runbook - Get Content
检索由 Runbook 名称标识的 Runbook 内容。
GET https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/content?api-version=2023-11-01
URI 参数
名称 | 在 | 必需 | 类型 | 说明 |
---|---|---|---|---|
automation
|
path | True |
string |
自动化帐户的名称。 |
resource
|
path | True |
string |
Azure 资源组的名称。 正则表达式模式: |
runbook
|
path | True |
string |
Runbook 名称。 正则表达式模式: |
subscription
|
path | True |
string |
获取唯一标识 Microsoft Azure 订阅的订阅凭据。 此订阅 ID 是每个服务调用的 URI 的一部分。 |
api-version
|
query | True |
string |
客户端 API 版本。 |
响应
名称 | 类型 | 说明 |
---|---|---|
200 OK |
file |
确定 Media Types: "text/powershell" |
Other Status Codes |
描述操作失败原因的自动化错误响应。 Media Types: "text/powershell" |
安全性
azure_auth
Azure Active Directory OAuth2 流
类型:
oauth2
流向:
implicit
授权 URL:
https://login.microsoftonline.com/common/oauth2/authorize
作用域
名称 | 说明 |
---|---|
user_impersonation | 模拟用户帐户 |
示例
Get runbook content
示例请求
GET https://management.azure.com/subscriptions/subid/resourceGroups/rg/providers/Microsoft.Automation/automationAccounts/ContoseAutomationAccount/runbooks/Get-AzureVMTutorial/content?api-version=2023-11-01
示例响应
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 }"
定义
ErrorResponse
操作失败的错误响应
名称 | 类型 | 说明 |
---|---|---|
code |
string |
错误代码 |
message |
string |
指示操作失败原因的错误消息。 |