Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Import-AzureRmAutomationRunbook failing, when trying to update an existing Powershell Workflow runbook #5679

Closed
vinaydam opened this issue Mar 6, 2018 · 7 comments
Assignees
Labels
Automation Service Attention This issue is responsible by Azure service team.

Comments

@vinaydam
Copy link

vinaydam commented Mar 6, 2018

Description

Import-AzureRmAutomationRunbook is returning a bad request, when we try to update an existing Powershell Workflow runbook.

Script/Steps for Reproduction

Import-AzureRmAutomationRunbook -Name [Runbook Name] -Path [Local Path] -AutomationAccountName [Automation account name] -ResourceGroupName [Resource Group Name] -Type PowerShellWorkflow -Force -Published -Debug

Module Version

5.4.1

Environment Data

Name                           Value                                                                                                                    
----                           -----                                                                                                                    
PSVersion                      5.1.16299.248                                                                                                            
PSEdition                      Desktop                                                                                                                  
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}                                                                                                  
BuildVersion                   10.0.16299.248                                                                                                           
CLRVersion                     4.0.30319.42000                                                                                                          
WSManStackVersion              3.0                                                                                                                      
PSRemotingProtocolVersion      2.3                                                                                                                      
SerializationVersion           1.1.0.1  

Debug Output

Import-AzureRmAutomationRunbook -Name [Runbook Name] -Path [Local Path] -AutomationAccountName [Automation account name] -ResourceGroupName [Resource Group Name] -Type PowerShellWorkflow -Force -Published -Debug
DEBUG: 5:09:23 PM - ImportAzureAutomationRunbook begin processing with ParameterSet '__AllParameterSets'.
DEBUG: 5:09:25 PM - using account id '[userid]'...
DEBUG: [Common.Authentication]: Authenticating using Account: '[userid]', environment: 'AzureCloud', tenant: 'bd3eeefe-e2f5-
40d6-abc6-bbb9c8f48d03'
DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 : 
DEBUG: 03/06/2018 11:39:26:  - TokenCache: Serializing token cache with 1 items.

DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 : 
DEBUG: 03/06/2018 11:39:26:  - TokenCache: Serializing token cache with 1 items.

DEBUG: [Common.Authentication]: Authenticating using configuration values: Domain: 'bd3eeefe-e2f5-40d6-abc6-bbb9c8f48d03', Endpoint: 'https://login.micro
softonline.com/', ClientId: '1950a258-227b-4e31-a9cf-717495945fc2', ClientRedirect: 'urn:ietf:wg:oauth:2.0:oob', ResourceClientUri: 'https://management.c
ore.windows.net/', ValidateAuthrity: 'True'
DEBUG: [Common.Authentication]: Acquiring token using context with Authority 'https://login.microsoftonline.com/bd3eeefe-e2f5-40d6-abc6-bbb9c8f48d03/', C
orrelationId: '00000000-0000-0000-0000-000000000000', ValidateAuthority: 'True'
DEBUG: [Common.Authentication]: Acquiring token using AdalConfiguration with Domain: 'bd3eeefe-e2f5-40d6-abc6-bbb9c8f48d03', AdEndpoint: 'https://login.m
icrosoftonline.com/', ClientId: '1950a258-227b-4e31-a9cf-717495945fc2', ClientRedirectUri: urn:ietf:wg:oauth:2.0:oob
DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 : 
DEBUG: 03/06/2018 11:39:26: cfa75df9-34c9-4821-bf38-ab78119896ab - AcquireTokenHandlerBase: === Token Acquisition started:
	Authority: https://login.microsoftonline.com/bd3eeefe-e2f5-40d6-abc6-bbb9c8f48d03/
	Resource: https://management.core.windows.net/
	ClientId: 1950a258-227b-4e31-a9cf-717495945fc2
	CacheType: Microsoft.Azure.Commands.Common.Authentication.AuthenticationStoreTokenCache (1 items)
	Authentication Target: User
	

DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Verbose: 1 : 
DEBUG: 03/06/2018 11:39:26: cfa75df9-34c9-4821-bf38-ab78119896ab - TokenCache: Looking up cache for a token...

DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 : 
DEBUG: 03/06/2018 11:39:26: cfa75df9-34c9-4821-bf38-ab78119896ab - TokenCache: An item matching the requested resource was found in the cache

DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Verbose: 1 : 
DEBUG: 03/06/2018 11:39:26: cfa75df9-34c9-4821-bf38-ab78119896ab - TokenCache: 43.3213972716667 minutes left until token in cache expires

DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 : 
DEBUG: 03/06/2018 11:39:26: cfa75df9-34c9-4821-bf38-ab78119896ab - TokenCache: A matching item (access token or refresh token or both) was found in the c
ache

DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 : 
DEBUG: 03/06/2018 11:39:26: cfa75df9-34c9-4821-bf38-ab78119896ab - AcquireTokenHandlerBase: === Token Acquisition finished successfully. An access token 
was retuned:
	Access Token Hash: eQeAq0inidY2FXA0aPHJCMBUU0sttaX8vNz8WjdbhcU=
	Refresh Token Hash: /wS6GN2m3J6otx4zfo87WyzXhNHy86M6tbSSrpGxGRI=
	Expiration Time: 03/06/2018 12:22:45 +00:00
	User Hash: Mk9l/pRzYF4eQmXWbqXQaY/LIcv6KvisB6i/dFJg36U=
	

DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 : 
DEBUG: 03/06/2018 11:39:26:  - TokenCache: Serializing token cache with 1 items.

DEBUG: [Common.Authentication]: Received token with LoginType 'LiveId', Tenant: 'bd3eeefe-e2f5-40d6-abc6-bbb9c8f48d03', UserId: '[userid]'
DEBUG: [Common.Authentication]: Renewing Token with Type: 'Bearer', Expiry: '03/06/2018 12:22:45 +00:00', MultipleResource? 'True', Tenant: 'bd3eeefe-e2f
5-40d6-abc6-bbb9c8f48d03', UserId: '[userid]'
DEBUG: [Common.Authentication]: User info for token DisplayId: '[userid]', Name: Vinay Damisetty, IdProvider: 'https://sts.w
indows.net/bd3eeefe-e2f5-40d6-abc6-bbb9c8f48d03/', Uid: '2a4b3d72-419c-43b2-9560-8ec7aad95a1b'
DEBUG: [Common.Authentication]: Checking token expiration, token expires '03/06/2018 12:22:45 +00:00' Comparing to '03/06/2018 11:39:26 +00:00' With thre
shold '00:05:00', calculated time until token expiry: '00:43:19.2838363'
DEBUG: ============================ HTTP REQUEST ============================

HTTP Method:
GET

Absolute Uri:
https://management.azure.com/subscriptions/[subscriptionid]/resourceGroups/[resourcegroupname]/providers/Microsoft.Automation/automat
ionAccounts/MAHSEW-AAA-0002-DEV/runbooks/Confirm-VM-Configuration?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               : 98c10d89-e91c-4b41-af0c-c1554b9f7129
Strict-Transport-Security     : max-age=31536000; includeSubDomains
x-ms-ratelimit-remaining-subscription-reads: 14999
x-ms-correlation-request-id   : 8deb3d38-f8ed-4060-bda6-d7bbe9aeafec
x-ms-routing-request-id       : SOUTHINDIA:20180306T113927Z:8deb3d38-f8ed-4060-bda6-d7bbe9aeafec
X-Content-Type-Options        : nosniff
Cache-Control                 : no-cache
Date                          : Tue, 06 Mar 2018 11:39:27 GMT
ETag                          : "636525732918070000"
Server                        : Microsoft-IIS/8.5
X-AspNet-Version              : 4.0.30319
X-Powered-By                  : ASP.NET

Body:
{
  "id": "/subscriptions/[subscriptionid]/resourceGroups/[resourcegroupname]/providers/Microsoft.Automation/automationAccounts/MAHSEW-
AAA-0002-DEV/runbooks/Confirm-VM-Configuration",
  "name": "Confirm-VM-Configuration",
  "type": "Microsoft.Automation/AutomationAccounts/Runbooks",
  "location": "westeurope",
  "tags": {},
  "etag": "\"636525732918070000\"",
  "properties": {
    "description": null,
    "logVerbose": false,
    "logProgress": false,
    "logActivityTrace": 0,
    "runbookType": "Script",
    "parameters": {
      "ResourceList": {
        "type": "System.Object[]",
        "isMandatory": true,
        "position": 0,
        "defaultValue": null
      }
    },
    "state": "Published",
    "jobCount": 0,
    "provisioningState": "Succeeded",
    "serviceManagementTags": null,
    "outputTypes": [],
    "creationTime": "2016-08-22T22:58:22.743+05:30",
    "lastModifiedBy": "Balazs.Somogyi-a@shellcorp2.onmicrosoft.com",
    "lastModifiedTime": "2018-01-26T19:51:31.807+05:30"
  }
}


DEBUG: [Common.Authentication]: Renewing Token with Type: 'Bearer', Expiry: '03/06/2018 12:22:45 +00:00', MultipleResource? 'True', Tenant: 'bd3eeefe-e2f
5-40d6-abc6-bbb9c8f48d03', UserId: '[userid]'
DEBUG: [Common.Authentication]: User info for token DisplayId: '[userid]', Name: Vinay Damisetty, IdProvider: 'https://sts.w
indows.net/bd3eeefe-e2f5-40d6-abc6-bbb9c8f48d03/', Uid: '2a4b3d72-419c-43b2-9560-8ec7aad95a1b'
DEBUG: [Common.Authentication]: Checking token expiration, token expires '03/06/2018 12:22:45 +00:00' Comparing to '03/06/2018 11:39:27 +00:00' With thre
shold '00:05:00', calculated time until token expiry: '00:43:17.6464935'
DEBUG: ============================ HTTP REQUEST ============================

HTTP Method:
GET

Absolute Uri:
https://management.azure.com/subscriptions/[subscriptionid]/resourceGroups/[resourcegroupname]/providers/Microsoft.Automation/automat
ionAccounts/MAHSEW-AAA-0002-DEV?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
ocp-automation-accountid      : 783e9089-cf28-4cca-9faf-08a0e51808be
x-ms-request-id               : 98c10d89-e91c-4b41-af0c-c1554b9f7129
Strict-Transport-Security     : max-age=31536000; includeSubDomains
x-ms-ratelimit-remaining-subscription-reads: 14998
x-ms-correlation-request-id   : a82ef73d-647e-44b8-99c5-bdbe6c98a75c
x-ms-routing-request-id       : SOUTHINDIA:20180306T113928Z:a82ef73d-647e-44b8-99c5-bdbe6c98a75c
X-Content-Type-Options        : nosniff
Cache-Control                 : no-cache
Date                          : Tue, 06 Mar 2018 11:39:27 GMT
Server                        : Microsoft-IIS/8.5
X-AspNet-Version              : 4.0.30319
X-Powered-By                  : ASP.NET

Body:
{
  "name": "MAHSEW-AAA-0002-DEV",
  "id": "/subscriptions/[subscriptionid]/resourceGroups/[resourcegroupname]/providers/Microsoft.Automation/automationAccounts/MAHSEW-
AAA-0002-DEV",
  "type": "Microsoft.Automation/AutomationAccounts",
  "location": "westeurope",
  "tags": {
    "Purpose": "Triggering Mechanism"
  },
  "etag": null,
  "properties": {
    "sku": {
      "name": "Basic",
      "family": null,
      "capacity": null
    },
    "state": "Ok",
    "RegistrationUrl": "https://we-agentservice-prod-1.azure-automation.net/accounts/783e9089-cf28-4cca-9faf-08a0e51808be",
    "creationTime": "2016-08-22T22:49:41.293+05:30",
    "lastModifiedBy": "yemrea-a@shellcorp2.onmicrosoft.com",
    "lastModifiedTime": "2017-11-29T13:59:50.96+05:30"
  }
}


DEBUG: [Common.Authentication]: Renewing Token with Type: 'Bearer', Expiry: '03/06/2018 12:22:45 +00:00', MultipleResource? 'True', Tenant: 'bd3eeefe-e2f
5-40d6-abc6-bbb9c8f48d03', UserId: '[userid]'
DEBUG: [Common.Authentication]: User info for token DisplayId: '[userid]', Name: Vinay Damisetty, IdProvider: 'https://sts.w
indows.net/bd3eeefe-e2f5-40d6-abc6-bbb9c8f48d03/', Uid: '2a4b3d72-419c-43b2-9560-8ec7aad95a1b'
DEBUG: [Common.Authentication]: Checking token expiration, token expires '03/06/2018 12:22:45 +00:00' Comparing to '03/06/2018 11:39:28 +00:00' With thre
shold '00:05:00', calculated time until token expiry: '00:43:17.4425817'
DEBUG: ============================ HTTP REQUEST ============================

HTTP Method:
PUT

Absolute Uri:
https://management.azure.com/subscriptions/[subscriptionid]/resourceGroups/[resourcegroupname]/providers/Microsoft.Automation/automat
ionAccounts/MAHSEW-AAA-0002-DEV/runbooks/Confirm-VM-Configuration?api-version=2015-10-31

Headers:
Accept                        : application/json
x-ms-version                  : 2014-06-01

Body:
{
  "properties": {
    "logVerbose": false,
    "logProgress": false,
    "runbookType": "PowerShellWorkflow",
    "draft": {
      "inEdit": false,
      "creationTime": "0001-01-01T05:30:00+05:30",
      "lastModifiedTime": "0001-01-01T05:30:00+05:30"
    },
    "logActivityTrace": 0
  },
  "name": "Confirm-VM-Configuration",
  "location": "westeurope"
}


DEBUG: ============================ HTTP RESPONSE ============================

Status Code:
BadRequest

Headers:
Pragma                        : no-cache
x-ms-request-id               : 98c10d89-e91c-4b41-af0c-c1554b9f7129
Strict-Transport-Security     : max-age=31536000; includeSubDomains
x-ms-ratelimit-remaining-subscription-writes: 1199
x-ms-correlation-request-id   : 1c93e034-7a92-4d01-8c1a-43835dce3be5
x-ms-routing-request-id       : SOUTHINDIA:20180306T113928Z:1c93e034-7a92-4d01-8c1a-43835dce3be5
X-Content-Type-Options        : nosniff
Cache-Control                 : no-cache
Date                          : Tue, 06 Mar 2018 11:39:28 GMT
Server                        : Microsoft-IIS/8.5
X-AspNet-Version              : 4.0.30319
X-Powered-By                  : ASP.NET

Body:
{
  "code": "BadRequest",
  "message": "Update runbook with definition of different runbook kind is not allowed."
}


Import-AzureRmAutomationRunbook : BadRequest: Update runbook with definition of different runbook kind is not allowed.
At line:1 char:1
+ Import-AzureRmAutomationRunbook -Name "Confirm-VM-Configuration" -Pat ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : CloseError: (:) [Import-AzureRmAutomationRunbook], CloudException
    + FullyQualifiedErrorId : Microsoft.Azure.Commands.Automation.Cmdlet.ImportAzureAutomationRunbook
 
DEBUG: AzureQoSEvent: CommandName - Import-AzureRmAutomationRunbook; IsSuccess - False; Duration - 00:00:06.3608398; Exception - Hyak.Common.CloudExcepti
on: BadRequest: Update runbook with definition of different runbook kind is not allowed.
   at Microsoft.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at Microsoft.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccess(Task task)
   at Microsoft.Azure.Management.Automation.RunbookOperationsExtensions.CreateOrUpdateWithDraft(IRunbookOperations operations, String resourceGroupName, 
String automationAccount, RunbookCreateOrUpdateDraftParameters parameters)
   at Microsoft.Azure.Commands.Automation.Common.AutomationClient.CreateRunbookByName(String resourceGroupName, String automationAccountName, String runb
ookName, String description, IDictionary tags, String type, Nullable`1 logProgress, Nullable`1 logVerbose, Boolean overwrite)
   at Microsoft.Azure.Commands.Automation.Common.AutomationClient.ImportRunbook(String resourceGroupName, String automationAccountName, String runbookPat
h, String description, IDictionary tags, String type, Nullable`1 logProgress, Nullable`1 logVerbose, Boolean published, Boolean overwrite, String name)
   at Microsoft.Azure.Commands.Automation.Cmdlet.ImportAzureAutomationRunbook.AutomationProcessRecord()
   at Microsoft.Azure.Commands.Automation.Cmdlet.AzureAutomationBaseCmdlet.ExecuteCmdlet()
   at Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePSCmdlet.ProcessRecord();
DEBUG: Finish sending metric.
DEBUG: 5:09:30 PM - ImportAzureAutomationRunbook end processing.
DEBUG: 5:09:30 PM - ImportAzureAutomationRunbook end processing.
@cormacpayne
Copy link
Member

@vrdmr Hey Varad, would you mind taking a look at this issue? It seems there might already be a runbook with the same name, but a different type. Do you know if this is the case, and if so, is this operation allowed?

@safeermohammed
Copy link
Contributor

The existing runbook, Type is returned as "runbookType": "Script", Script was a legacy value for PowerShellWorkflow. So seems like this is causing a BadRequest to be thrown on Re-PUT as PUT is sending runbookType: PowerShellWorkflow. This is a bug in service. As a workaround, Is it okay to delete and recreate the Runbook? Latest PUT will replace the legacy value Script to PowerShellWorkflow and there will be no badrequest reported. Get call will also return the runbookType:PowerShellWorkflow instead of legacy value.

@vinaydam
Copy link
Author

vinaydam commented Mar 7, 2018

@safeermohammed Thanks for the response. We can delete and recreate the runbook in the Dev environment. But, we can't do that in the production environment. Could you please let me know when can we expect a fix for this issue?

@hermot
Copy link

hermot commented Mar 14, 2018

Out of curiosity, what happens to an existing runbook when the import of a new runbook failed?
I am doing an import over an existing one with the force flag, but would like to know if Azure ensures the integrity of the original version of the runbook in the case that the import of a new version thereof fails?

@safeermohammed
Copy link
Contributor

safeermohammed commented Mar 15, 2018

The existing runbook remains intact if the new runbook publish fails.

@safeermohammed
Copy link
Contributor

assigning to @najams

@vrdmr vrdmr removed their assignment Mar 30, 2018
@safeermohammed
Copy link
Contributor

Fix was in b/e and it is deployed. Can you please try now? Please reopen the issue if it still repro's.

@bsiegel bsiegel added the Service Attention This issue is responsible by Azure service team. label Sep 26, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Automation Service Attention This issue is responsible by Azure service team.
Projects
None yet
Development

No branches or pull requests

7 participants