Azure / Azure/azure-powershell
Start-AzureRmAutomationRunbook cannot pass parameters to a Python runbook
- Dominant language
- C#
- Stars
- 4.8k
- Forks
- 4.3k
- Avg merge
- 2d 17h
- Merged PRs (30d)
- 51
Description
### Cmdlet(s)
Start-AzureRmAutomationRunbook
### PowerShell Version
5.1.16299.98
### Module Version
2.1.0
### OS Version
10.0.16299.98
### Description
Start-AzureRmAutomationRunbook cannot pass parameters to a Python runbook
### Debug Output
DEBUG: 11:22:13 AM - StartAzureAutomationRunbook begin processing with ParameterSet 'ByAsynchronousReturnJob'.
DEBUG: 11:22:13 AM - using account id ''...
DEBUG: [Common.Authentication]: Authenticating using Account: '', environment: 'AzureCloud', tenant:
'72f988bf-86f1-41af-91ab-2d7cd011db47'
DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 :
DEBUG: 01/19/2018 19:22:13: - TokenCache: Deserialized 1 items to token cache.
DEBUG: [Common.Authentication]: Authenticating using configuration values: Domain:
'72f988bf-86f1-41af-91ab-2d7cd011db47', Endpoint: 'https://login.microsoftonline.com/', ClientId:
'1950a258-227b-4e31-a9cf-717495945fc2', ClientRedirect: 'urn:ietf:wg:oauth:2.0:oob', ResourceClientUri:
'https://management.core.windows.net/', ValidateAuthrity: 'True'
DEBUG: [Common.Authentication]: Acquiring token using context with Authority
'https://login.microsoftonline.com/72f988bf-86f1-41af-91ab-2d7cd011db47/', CorrelationId:
'00000000-0000-0000-0000-000000000000', ValidateAuthority: 'True'
DEBUG: [Common.Authentication]: Acquiring token using AdalConfiguration with Domain:
'72f988bf-86f1-41af-91ab-2d7cd011db47', AdEndpoint: 'https://login.microsoftonline.com/', ClientId:
'1950a258-227b-4e31-a9cf-717495945fc2', ClientRedirectUri: urn:ietf:wg:oauth:2.0:oob
DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 :
DEBUG: 01/19/2018 19:22:13: 7bb61a0f-9fec-411c-a58b-539281347380 - AcquireTokenHandlerBase: === Token Acquisition
started:
Authority: https://login.microsoftonline.com/72f988bf-86f1-41af-91ab-2d7cd011db47/
Resource: https://management.core.windows.net/
ClientId: 1950a258-227b-4e31-a9cf-717495945fc2
CacheType: Microsoft.IdentityModel.Clients.ActiveDirectory.TokenCache (1 items)
Authentication Target: User
DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Verbose: 1 :
DEBUG: 01/19/2018 19:22:13: 7bb61a0f-9fec-411c-a58b-539281347380 - TokenCache: Looking up cache for a token...
DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 :
DEBUG: 01/19/2018 19:22:13: 7bb61a0f-9fec-411c-a58b-539281347380 - TokenCache: An item matching the requested resource
was found in the cache
DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Verbose: 1 :
DEBUG: 01/19/2018 19:22:13: 7bb61a0f-9fec-411c-a58b-539281347380 - TokenCache: 15.5161177733333 minutes left until
token in cache expires
DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 :
DEBUG: 01/19/2018 19:22:13: 7bb61a0f-9fec-411c-a58b-539281347380 - TokenCache: A matching item (access token or refresh
token or both) was found in the cache
DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 :
DEBUG: 01/19/2018 19:22:13: 7bb61a0f-9fec-411c-a58b-539281347380 - AcquireTokenHandlerBase: === Token Acquisition
finished successfully. An access token was retuned:
Access Token Hash: UYRG251SWj4CyWhXrlTUoc5OFuwtUfeeyy4Sy3SUm94=
Refresh Token Hash: eJeomWzrS+BuENPEQthaAl1GaMGVoGYVr8TMVX2k+F8=
Expiration Time: 01/19/2018 19:37:44 +00:00
User Hash: 6nybKRORpRbnbrZZvB4vem4/OL6/60e4XGX277ON6II=
DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 :
DEBUG: 01/19/2018 19:22:13: - TokenCache: Serializing token cache with 1 items.
DEBUG: [Common.Authentication]: Received token with LoginType 'LiveId', Tenant: '72f988bf-86f1-41af-91ab-2d7cd011db47',
UserId: ''
DEBUG: [Common.Authentication]: Renewing Token with Type: 'Bearer', Expiry: '01/19/2018 19:37:44 +00:00',
MultipleResource? 'True', Tenant: '72f988bf-86f1-41af-91ab-2d7cd011db47', UserId: ''
DEBUG: [Common.Authentication]: User info for token DisplayId: '', Name: Brandon Poe, IdProvider:
'https://sts.windows.net/72f988bf-86f1-41af-91ab-2d7cd011db47/', Uid: 'c1ce9973-726b-4ad5-b065-eb7aeac317d9'
DEBUG: [Common.Authentication]: Checking token expiration, token expires '01/19/2018 19:37:44 +00:00' Comparing to
'01/19/2018 19:22:13 +00:00' With threshold '00:05:00', calculated time until token expiry: '00:15:30.9655645'
DEBUG: ============================ HTTP REQUEST ============================
HTTP Method:
GET
Absolute Uri:
https://management.azure.com/subscriptions/xxxx/resourceGroups/xxxx/providers/M
icrosoft.Automation/automationAccounts/xxxx/runbooks/HelloWorldPy?api-version=2015-10-31
Headers:
Accept : application/json
x-ms-version : 2014-06-01
Body:
DEBUG: ============================ HTTP RESPONSE ============================
Status Code:
OK
Headers:
Pragma : no-cache
x-ms-request-id : 722b50b4-95fe-48fb-9d09-00b9b02fb644
Strict-Transport-Security : max-age=31536000; includeSubDomains
x-ms-ratelimit-remaining-subscription-reads: 14756
x-ms-correlation-request-id : 6ba69eee-d56a-469d-9f3a-9d9eb80bb62d
x-ms-routing-request-id : WESTUS2:20180119T192216Z:6ba69eee-d56a-469d-9f3a-9d9eb80bb62d
Cache-Control : no-cache
Date : Fri, 19 Jan 2018 19:22:15 GMT
ETag : "636519835787830000"
Server : Microsoft-IIS/8.5
X-AspNet-Version : 4.0.30319
X-Powered-By : ASP.NET
Body:
{
"id":
"/subscriptions/xxxx/resourceGroups/xxxx/providers/Microsoft.Automation/automat
ionAccounts/xxxx/runbooks/HelloWorldPy",
"name": "HelloWorldPy",
"type": "Microsoft.Automation/AutomationAccounts/Runbooks",
"location": "northcentralus",
"tags": {},
"etag": "\"636519835787830000\"",
"properties": {
"description": null,
"logVerbose": false,
"logProgress": false,
"logActivityTrace": 0,
"runbookType": "Python2",
"parameters": {},
"state": "Published",
"jobCount": 0,
"provisioningState": "Succeeded",
"serviceManagementTags": null,
"outputTypes": [],
"creationTime": "2018-01-19T10:14:50.553-08:00",
"lastModifiedBy": "",
"lastModifiedTime": "2018-01-19T10:32:58.783-08:00"
}
}
Start-AzureRmAutomationRunbook : Invalid runbook parameters.
At line:1 char:1
+ Start-AzureRmAutomationRunbook -ResourceGroupName xxxx -Autom ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : CloseError: (:) [Start-AzureRmAutomationRunbook], ArgumentException
+ FullyQualifiedErrorId : Microsoft.Azure.Commands.Automation.Cmdlet.StartAzureAutomationRunbook
DEBUG: AzureQoSEvent: CommandName - Start-AzureRmAutomationRunbook; IsSuccess - False; Duration - 00:00:00.6157873;
Exception - System.ArgumentException: Invalid runbook parameters.
at Microsoft.Azure.Commands.Automation.Common.AutomationClient.ProcessRunbookParameters(String resourceGroupName,
String automationAccountName, String runbookName, IDictionary parameters)
at Microsoft.Azure.Commands.Automation.Common.AutomationClient.StartRunbook(String resourceGroupName, String
automationAccountName, String runbookName, IDictionary parameters, String runOn)
at Microsoft.Azure.Commands.Automation.Cmdlet.StartAzureAutomationRunbook.AutomationProcessRecord()
at Microsoft.Azure.Commands.Automation.Cmdlet.AzureAutomationBaseCmdlet.ExecuteCmdlet()
at Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePSCmdlet.ProcessRecord();
DEBUG: Finish sending metric.
DEBUG: 11:22:14 AM - StartAzureAutomationRunbook end processing.
DEBUG: 11:22:14 AM - StartAzureAutomationRunbook end processing.
### Script/Steps for Reproduction
1. Create a simple Python runbook and publish it:
import sys
print 'Argument List:', str(sys.argv)
2. Attempt to pass parameters to the runbook when calling Start-AzureRmAutomationRunbook:
Start-AzureRmAutomationRunbook -ResourceGroupName xxxx -AutomationAccountName xxxx -Name H
elloWorldPy -Parameters @{ "[Parameter 1]" = "arg1 arg2 arg3" }
The problem occurs in AutomationClient.ProcessRunbookParameters. We get the runbook and enumerate its parameters and only map the supplied parameters to the runbooks parameters. Python runbooks do not have enumerable parameters. In the case of a Python runbook, we need to just pass any user supplied parameters without attempting to map them.
Contributor guide
Assessment
This issue has not been assessed yet.