Azure / Azure/azure-powershell

Set-AzureRmAutomationModule does not update module in Automation account

Open
#5,064 5 comments 1 reaction 3 assignees Claimed by @GaneshMSAzure View on GitHub
act-codegen-extensibility-squad Automation automation-modules customer-reported Up for grabs
Dominant language
C#
Stars
4.8k
Forks
4.3k
Avg merge
2d 17h
Merged PRs (30d)
51

Description

### Cmdlet(s)
Set-AzureRmAutomationModule

### PowerShell Version
5.1.14393.1884

### Module Version
4.0.0

### OS Version
10.0.14393.1884

### Description
The **Set-AzureRmAutomationModule** cmdlet appears to have no effect when attempting to update a module in a target automation account. The module reports in the portal that it is importing a later version and reports success, however the module remains unchanged.
Attempting the same with **New-AzureRmAutomationModule** successfully updates the module to the new version as expected, as does importing the new version through the upload facility in the portal.

### Debug Output
```
13:34:19 - SetAzureAutomationModule begin processing with ParameterSet 'ByName'.
13:34:19 - using account id 'jim@***************.com'...
[Common.Authentication]: Authenticating using Account: 'jim@***************.com', environment: 'AzureCloud', tenant: '********-****-****-****-************'
Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 :
12/01/2017 13:34:19: - TokenCache: Serializing token cache with 4 items.

Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 :
12/01/2017 13:34:19: - TokenCache: Serializing token cache with 4 items.

[Common.Authentication]: Authenticating using configuration values: Domain: '********-****-****-****-************', Endpoint: 'https://login.microsoftonline.com/', ClientId: '********-****-****-****-************', ClientRedirect: 'urn:ietf:wg:oauth:2.0:oob', ResourceClientUri: 'https://management.core.windows.net/', ValidateAuthrity: 'True'
[Common.Authentication]: Acquiring token using context with Authority 'https://login.microsoftonline.com/********-****-****-****-************/', CorrelationId: '00000000-0000-0000-0000-000000000000', ValidateAuthority: 'True'
[Common.Authentication]: Acquiring token using AdalConfiguration with Domain: '********-****-****-****-************', AdEndpoint: 'https://login.microsoftonline.com/', ClientId: '********-****-****-****-************', ClientRedirectUri: urn:ietf:wg:oauth:2.0:oob
Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 :
12/01/2017 13:34:19: 0f4b8592-8bb4-4444-b548-bd07bdabd4e4 - AcquireTokenHandlerBase: === Token Acquisition started:
Authority: https://login.microsoftonline.com/********-****-****-****-************/
Resource: https://management.core.windows.net/
ClientId: 1950a258-227b-4e31-a9cf-717495945fc2
CacheType: Microsoft.Azure.Commands.Common.Authentication.AuthenticationStoreTokenCache (4 items)
Authentication Target: User

Microsoft.IdentityModel.Clients.ActiveDirectory Verbose: 1 :
12/01/2017 13:34:19: 0f4b8592-8bb4-4444-b548-bd07bdabd4e4 - TokenCache: Looking up cache for a token...

Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 :
12/01/2017 13:34:19: 0f4b8592-8bb4-4444-b548-bd07bdabd4e4 - TokenCache: An item matching the requested resource was found in the cache

Microsoft.IdentityModel.Clients.ActiveDirectory Verbose: 1 :
12/01/2017 13:34:19: 0f4b8592-8bb4-4444-b548-bd07bdabd4e4 - TokenCache: 53.8539774466667 minutes left until token in cache expires

Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 :
12/01/2017 13:34:19: 0f4b8592-8bb4-4444-b548-bd07bdabd4e4 - TokenCache: A matching item (access token or refresh token or both) was found in the cache

Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 :
12/01/2017 13:34:19: 0f4b8592-8bb4-4444-b548-bd07bdabd4e4 - AcquireTokenHandlerBase: === Token Acquisition finished successfully. An access token was retuned:
Access Token Hash: da6CWP8JzRqsN/a2S9+TRTDx9BUn1ZJsInT7zGPSNsY=
Refresh Token Hash: hPXm/BNj2c58R7bMm4QD3tIyzmddemqUmufZ3Km1xnU=
Expiration Time: 12/01/2017 14:28:10 +00:00
User Hash: bdG8EjSC7P3ZY3KRiPrKmURwepDK+ulolviQ3reAVtg=

Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 :
12/01/2017 13:34:19: - TokenCache: Serializing token cache with 4 items.

[Common.Authentication]: Received token with LoginType 'LiveId', Tenant: '********-****-****-****-************', UserId: 'jim@***************.com'
[Common.Authentication]: Renewing Token with Type: 'Bearer', Expiry: '12/01/2017 14:28:10 +00:00', MultipleResource? 'True', Tenant: '********-****-****-****-************', UserId: 'jim@***************.com'
[Common.Authentication]: User info for token DisplayId: 'jim@***************.com', Name: Jim Paton, IdProvider: 'https://sts.windows.net/********-****-****-****-************/', Uid: 'd7d091a4-7718-4025-bfa7-2308a9207513'
[Common.Authentication]: Checking token expiration, token expires '12/01/2017 14:28:10 +00:00' Comparing to '12/01/2017 13:34:19 +00:00' With threshold '00:05:00', calculated time until token expiry: '00:53:51.2386468'
============================ HTTP REQUEST ============================

HTTP Method:
GET

Absolute Uri:
https://management.azure.com/subscriptions/********-****-****-****-************/resourceGroups/dev-jim-resource-group/providers/Microsoft.Automation/automationAccounts/dev-jim-automation/modules/TestModule?api-version=2015-10-31

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

Body:

============================ HTTP RESPONSE ============================

Status Code:
OK

Headers:
Pragma : no-cache
x-ms-request-id : 5d1a8c73-d98b-46ef-b2a3-4b96048baf2a
Strict-Transport-Security : max-age=31536000; includeSubDomains
x-ms-ratelimit-remaining-subscription-reads: 14988
x-ms-correlation-request-id : b94afd32-0eaa-4d92-9dc6-61af4a4b126c
x-ms-routing-request-id : WESTEUROPE:20171201T133420Z:b94afd32-0eaa-4d92-9dc6-61af4a4b126c
Cache-Control : no-cache
Date : Fri, 01 Dec 2017 13:34:20 GMT
Server : Microsoft-IIS/8.5
X-AspNet-Version : 4.0.30319
X-Powered-By : ASP.NET

Body:
{
"id": "/subscriptions/********-****-****-****-************/resourceGroups/dev-jim-resource-group/providers/Microsoft.Automation/automationAccounts/dev-jim-automation/modules/TestModule",
"name": "TestModule",
"type": "Microsoft.Automation/AutomationAccounts/Modules",
"location": "westeurope",
"tags": {},
"etag": null,
"properties": {
"isGlobal": false,
"version": "0.1.0",
"sizeInBytes": 1973,
"activityCount": 1,
"creationTime": "2017-12-01T13:28:11.81+00:00",
"lastModifiedTime": "2017-12-01T13:29:16.107+00:00",
"error": {
"code": null,
"message": ""
},
"provisioningState": "Succeeded"
}
}

[Common.Authentication]: Renewing Token with Type: 'Bearer', Expiry: '12/01/2017 14:28:10 +00:00', MultipleResource? 'True', Tenant: '********-****-****-****-************', UserId: 'jim@***************.com'
[Common.Authentication]: User info for token DisplayId: 'jim@***************.com', Name: Jim Paton, IdProvider: 'https://sts.windows.net/********-****-****-****-************/', Uid: 'd7d091a4-7718-4025-bfa7-2308a9207513'
[Common.Authentication]: Checking token expiration, token expires '12/01/2017 14:28:10 +00:00' Comparing to '12/01/2017 13:34:20 +00:00' With threshold '00:05:00', calculated time until token expiry: '00:53:50.2550471'
============================ HTTP REQUEST ============================

HTTP Method:
PATCH

Absolute Uri:
https://management.azure.com/subscriptions/********-****-****-****-************/resourceGroups/dev-jim-resource-group/providers/Microsoft.Automation/automationAccounts/dev-jim-automation/modules/TestModule?api-version=2015-10-31

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

Body:
{
"properties": {
"contentLink": {
"uri": "https://******************.blob.core.windows.net/psrepository/TestModule-0.2.0.zip?st=2017-11-30T00%3A00%3A00Z&se=2018-01-01T00%3A00%3A00Z&sp=r&sv=2017-04-17&sr=b&sig=RwIqmVuaBqd3iMXWKLWypRHV87W01aYO1rzwlPMkMJo%3D",
"version": "0.2.0"
}
},
"name": "TestModule",
"tags": {}
}

============================ HTTP RESPONSE ============================

Status Code:
OK

Headers:
Pragma : no-cache
x-ms-request-id : 5d1a8c73-d98b-46ef-b2a3-4b96048baf2a
Strict-Transport-Security : max-age=31536000; includeSubDomains
x-ms-ratelimit-remaining-subscription-writes: 1199
x-ms-correlation-request-id : 61d9e655-2cce-4a8b-9be8-c46e213b633c
x-ms-routing-request-id : WESTEUROPE:20171201T133421Z:61d9e655-2cce-4a8b-9be8-c46e213b633c
Cache-Control : no-cache
Date : Fri, 01 Dec 2017 13:34:21 GMT
Server : Microsoft-IIS/8.5
X-AspNet-Version : 4.0.30319
X-Powered-By : ASP.NET

Body:
{
"id": "/subscriptions/********-****-****-****-************/resourceGroups/dev-jim-resource-group/providers/Microsoft.Automation/automationAccounts/dev-jim-automation/modules/TestModule",
"name": "TestModule",
"type": "Microsoft.Automation/AutomationAccounts/Modules",
"location": "westeurope",
"tags": {},
"etag": null,
"properties": {
"isGlobal": false,
"version": "0.1.0",
"sizeInBytes": 1973,
"activityCount": 1,
"creationTime": "2017-12-01T13:28:11.81+00:00",
"lastModifiedTime": "2017-12-01T13:29:16.107+00:00",
"error": {
"code": null,
"message": null
},
"provisioningState": "Creating"
}
}

[Common.Authentication]: Renewing Token with Type: 'Bearer', Expiry: '12/01/2017 14:28:10 +00:00', MultipleResource? 'True', Tenant: '********-****-****-****-************', UserId: 'jim@***************.com'
[Common.Authentication]: User info for token DisplayId: 'jim@***************.com', Name: Jim Paton, IdProvider: 'https://sts.windows.net/********-****-****-****-************/', Uid: 'd7d091a4-7718-4025-bfa7-2308a9207513'
[Common.Authentication]: Checking token expiration, token expires '12/01/2017 14:28:10 +00:00' Comparing to '12/01/2017 13:34:21 +00:00' With threshold '00:05:00', calculated time until token expiry: '00:53:49.3391214'
============================ HTTP REQUEST ============================

HTTP Method:
GET

Absolute Uri:
https://management.azure.com/subscriptions/********-****-****-****-************/resourceGroups/dev-jim-resource-group/providers/Microsoft.Automation/automationAccounts/dev-jim-automation/modules/TestModule?api-version=2015-10-31

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

Body:

============================ HTTP RESPONSE ============================

Status Code:
OK

Headers:
Pragma : no-cache
x-ms-request-id : 5d1a8c73-d98b-46ef-b2a3-4b96048baf2a
Strict-Transport-Security : max-age=31536000; includeSubDomains
x-ms-ratelimit-remaining-subscription-reads: 14987
x-ms-correlation-request-id : 4670bc16-5d51-4fcd-aadc-453873beb4b6
x-ms-routing-request-id : WESTEUROPE:20171201T133421Z:4670bc16-5d51-4fcd-aadc-453873beb4b6
Cache-Control : no-cache
Date : Fri, 01 Dec 2017 13:34:21 GMT
Server : Microsoft-IIS/8.5
X-AspNet-Version : 4.0.30319
X-Powered-By : ASP.NET

Body:
{
"id": "/subscriptions/********-****-****-****-************/resourceGroups/dev-jim-resource-group/providers/Microsoft.Automation/automationAccounts/dev-jim-automation/modules/TestModule",
"name": "TestModule",
"type": "Microsoft.Automation/AutomationAccounts/Modules",
"location": "westeurope",
"tags": {},
"etag": null,
"properties": {
"isGlobal": false,
"version": "0.1.0",
"sizeInBytes": 1973,
"activityCount": 1,
"creationTime": "2017-12-01T13:28:11.81+00:00",
"lastModifiedTime": "2017-12-01T13:34:20.94+00:00",
"error": {
"code": null,
"message": ""
},
"provisioningState": "Creating"
}
}

Microsoft.Azure.Commands.Automation.Model.Module
AzureQoSEvent: CommandName - Set-AzureRmAutomationModule; IsSuccess - True; Duration - 00:00:02.0516138; Exception - ;
Finish sending metric.
13:34:22 - SetAzureAutomationModule end processing.
13:34:22 - SetAzureAutomationModule end processing.
```
### Script/Steps for Reproduction
1. Create a minimal Powershell module with .psm1 and .psd1 files and create two zip packages with version 0.1.0 & 0.2.0. Upload the packages to a location in Azure Blob Storage and generate a SAS uri for each.
2. Upload version 0.1.0 of the module to the target automation account using New-AzureRmAutomationModule with the SAS uri for the version 0.1.0 zip package.
``` powershell
New-AzureRmAutomationModule -AutomationAccountName $AutomationAccountName -Name $ModuleName -ContentLinkUri $SASUriV010 -ResourceGroupName $ResourceGroupName
```
The portal shows the module status as "importing", and then "available" when the import is complete.

3. Attempt to upload version 0.2.0 of the module to the target automation account using Set-AzureRmAutomationModule with the SAS uri for the version 0.2.0 zip package.
``` powershell
Set-AzureRmAutomationModule -AutomationAccountName $AutomationAccountName -Name $ModuleName -ContentLinkUri $SASUriV020 -ContentLinkVersion '0.2.0' -ResourceGroupName $ResourceGroupName
```
The portal shows the module status as "importing newer version"; however when the status changes to "available", the module has not been updated.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.