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

Default Environment Context 'AzureChinaCloud' #411

Closed
brettmillerb opened this issue Mar 12, 2021 · 2 comments
Closed

Default Environment Context 'AzureChinaCloud' #411

brettmillerb opened this issue Mar 12, 2021 · 2 comments
Assignees
Labels
bug The issue is a bug. needs investigation The issue needs to be investigated by the maintainers or/and the community.

Comments

@brettmillerb
Copy link

I have just downloaded the latest version from the gallery today and when creating a new context the default value that gets assigned to the context is 'AzureChinaCloud'. Even I try overriding by specifying the Environment parameter.

$cosmosAccount = Get-AzCosmosDBAccount -ResourceGroupName $ResourceGroupName
$accountkey = $cosmosAccount | Get-AzCosmosDBAccountKey | Select-Object -ExpandProperty PrimaryMasterKey
$secureAccountKey = ConvertTo-SecureString -String $accountkey -AsPlainText -Force
$cosmosDatabase = $cosmosAccount | Get-AzCosmosDBSqlDatabase

$cosmosDbContext = New-CosmosDbContext -Account $cosmosAccount.Name -Database $cosmosDatabase.name -Key $secureAccountKey -Environment AzureCloud

Result:

Account       : cosmos-dev
Database      : storage
Key           : System.Security.SecureString
KeyType       : master
BaseUri       : https://<baseUri>.documents.azure.com/
Token         : 
BackoffPolicy : 
Environment   : AzureChinaCloud

Environment:

ModuleType Version    PreRelease Name
---------- -------    ---------- ----
Script     4.4.3                 CosmosDB
Name                           Value
----                           -----
PSVersion                      7.1.0-rc.2
PSEdition                      Core
GitCommitId                    7.1.0-rc.2
OS                             Darwin 20.3.0 Darwin Kernel Version 20.3.0: Thu Jan 21 00:07:06 PST 2021; root:xnu-7195.81.3~1/RELEASE_X86_64
Platform                       Unix
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

I tried debugging execution but it looks to be setting the value correctly to AzureCloud so not sure how it's ending up as AzureChinaCloud in the returned object.

It hits the Account value in the switch here:
https://github.com/PlagueHO/CosmosDB/blob/main/source/Public/utils/New-CosmosDbContext.ps1#L166-L169

Even inside the Get-CosmosDbUri function, $environment is showing AzureCloud
image

I can see that there is no Environment being passed into the context object here:

https://github.com/PlagueHO/CosmosDB/blob/main/source/Public/utils/New-CosmosDbContext.ps1#L184-L192

Not sure if that's the cause or not. Will try and debug some more over the weekend to find out. Unfortunately the class object is not visible in the debugger when stepping through the code.

@PlagueHO PlagueHO added bug The issue is a bug. needs investigation The issue needs to be investigated by the maintainers or/and the community. labels May 22, 2021
@PlagueHO PlagueHO self-assigned this May 22, 2021
@PlagueHO
Copy link
Owner

It looks like it's just not setting the value before returning the Context object. Is an easy fix and I'll correct it now. Unit tests should also pick this up in future.

@PlagueHO
Copy link
Owner

This has been fixed now with PR #416

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug The issue is a bug. needs investigation The issue needs to be investigated by the maintainers or/and the community.
Projects
None yet
Development

No branches or pull requests

2 participants