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

Set-CosmosDbOffer fails with "Unauthorized" #85

Closed
dl8on opened this Issue Apr 23, 2018 · 4 comments

Comments

Projects
None yet
3 participants
@dl8on
Copy link

commented Apr 23, 2018

The Set-CosmosDbOffer cmdlet is currently failing with the following output:

Invoke-RestMethod : {"code":"Unauthorized","message":"The input authorization   
token can't serve the request. Please check that the expected payload is built 
as per the protocol, and check the key being used. Server used the following 
payload to sign: 'put\noffers\n{removed}\nmon, 23 apr 2018 15:47:13 
gmt\n\n'\r\nActivityId: {removed}, 
Microsoft.Azure.Documents.Common/1.21.0.0"}
At /usr/local/microsoft/powershell/6.0.0-beta.7/Modules/CosmosDB/2.0.9.364/lib/
utils.ps1:402 char:23
+         $restResult = Invoke-RestMethod @invokeRestMethodParameters
+                       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (Method: PUT, Re...ication/jso 
   n
}:HttpRequestMessage) [Invoke-RestMethod], HttpResponseException
    + FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShe 
   ll.Commands.InvokeRestMethodCommand

The fix seems to be relatively simple and straightforward. There just needs to be a .ToLowerInvariant() added to the end of Line 327 in the /src/lib/utils.ps1 file.

My local environment details:

$PSVersionTable | Format-List               


Name  : PSVersion
Value : 6.0.0-beta

Name  : PSEdition
Value : Core

Name  : GitCommitId
Value : v6.0.0-beta.7

Name  : OS
Value : Darwin 17.5.0 Darwin Kernel Version 17.5.0: Mon Mar  5 22:24:32 PST 
        2018; root:xnu-4570.51.1~1/RELEASE_X86_64

Name  : Platform
Value : Unix

Name  : PSCompatibleVersions
Value : {1.0, 2.0, 3.0, 4.0...}

Name  : PSRemotingProtocolVersion
Value : 2.3

Name  : SerializationVersion
Value : 1.1.0.1

Name  : WSManStackVersion
Value : 3.0
Get-Module -Name CosmosDB | Format-List     


Name              : CosmosDB
Path              : /usr/local/microsoft/powershell/6.0.0-beta.7/Modules/Cosmos
                    DB/2.0.9.364/CosmosDB.psm1
Description       : This module provides cmdlets for working with Azure Cosmos 
                    DB databases, collections, documents, attachments, offers, 
                    users, permissions, triggers, stored procedures and user 
                    defined functions.
ModuleType        : Script
Version           : 2.0.9.364
NestedModules     : {}
ExportedFunctions : {Get-CosmosDbAttachment, 
                    Get-CosmosDbAttachmentResourcePath, 
                    Get-CosmosDbCollection, 
                    Get-CosmosDbCollectionResourcePath...}
ExportedCmdlets   : 
ExportedVariables : 
ExportedAliases   : New-CosmosDbConnection
@PlagueHO

This comment has been minimized.

Copy link
Owner

commented Apr 24, 2018

Thanks for raising this @dl8on - great catch! I've got a day off tomorrow so I'm going to get some work done on this project (including finally getting the integration tests working). I'll add this at the same time.

Thanks for raising this!

@paylocity-sflanders

This comment has been minimized.

Copy link

commented Apr 24, 2018

I hit this today as well on the windows version. The update definitely fixes my issue

PS C:\Code\Corp\CMT\Paylocity.Apis.ContentManagement.Template\Provision> Get-Module -Name CosmosDB | Format-List

Name : CosmosDB
Path : C:\Users\SFlanders\Documents\WindowsPowerShell\Modules\CosmosDB\2.0.9.364\CosmosDB.psm1
Description : This module provides cmdlets for working with Azure Cosmos DB databases, collections, documents, attachments, offers, users, permissions, triggers, stored procedures and user defined functions.
ModuleType : Script
Version : 2.0.9.364
NestedModules : {}
ExportedFunctions : {Get-CosmosDbAttachment, Get-CosmosDbAttachmentResourcePath, Get-CosmosDbCollection, Get-CosmosDbCollectionResourcePath...}
ExportedCmdlets :
ExportedVariables :
ExportedAliases : New-CosmosDbConnection

dl8on added a commit to dl8on/CosmosDB that referenced this issue Apr 24, 2018

@PlagueHO PlagueHO added in progress and removed help wanted labels Apr 25, 2018

@PlagueHO

This comment has been minimized.

Copy link
Owner

commented Apr 25, 2018

I'm just about to commit the changes for this including regression tests that will validate this in future. Should be through to the PS Gallery by tomorrow. Thanks for your help!

@PlagueHO PlagueHO closed this in 31a6058 Apr 25, 2018

@PlagueHO

This comment has been minimized.

Copy link
Owner

commented Apr 25, 2018

This has now been released to PSGallery. Thanks again for your help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.