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
Add support for Azure Government URI #322
Comments
Hi @Cj-Scott - great suggestion. Should be easy enough to add to |
This has been completed in #346 and will be released in 3.7.0 shortly. |
@PlagueHO , we are using CosmosDB 2.1.15.239 version and cannot currently upgrade to 3.7.0. |
Hi @LenaVinogradov , It depends on how you are calling E.g. $primaryKey = ConvertTo-SecureString -String 'GFJqJesi2Rq910E0G7P4WoZkzowzbj23Sm9DUWFX0l0P8o16mYyuaZBN00Nbtj9F1QQnumzZKSGZwknXGERrlA==' -AsPlainText -Force
$cosmosDbContext = New-CosmosDbContext -Account 'MyAzureCosmosDB' -Database 'MyDatabase' -Key $primaryKey
$cosmosDbContext.BaseUri = 'https://MyAzureCosmosDB.documents.azure.us' However, any of the Does that help? |
Hi Daniel,
Thank you.
We are using it like this:
$context = @{
Account = $Name
Database = $DatabaseName
Key = (ConvertTo-SecureString $AccessKey -AsPlainText -Force)
}
$context = (New-CosmosDbContext @context)
$existing = Get-CosmosDbDatabase -Context $context | Where-Object Id -eq $DatabaseName
I am looking at the source of Get-CosmosDBDatabase and it doesn’t look like it’s calling *-AzureRmCosmosDB cmdlets. Am I missing something?
function Get-CosmosDbDatabase
{
[CmdletBinding(DefaultParameterSetName = 'Context')]
[OutputType([Object])]
param
(
[Alias("Connection")]
[Parameter(Mandatory = $true, ParameterSetName = 'Context')]
[ValidateNotNullOrEmpty()]
[CosmosDb.Context]
$Context,
[Parameter(Mandatory = $true, ParameterSetName = 'Account')]
[ValidateScript({ Assert-CosmosDbAccountNameValid -Name $_ -ArgumentName 'Account' })]
[System.String]
$Account,
[Parameter()]
[ValidateNotNullOrEmpty()]
[System.Security.SecureString]
$Key,
[Parameter()]
[ValidateSet('master', 'resource')]
[System.String]
$KeyType = 'master',
[Parameter()]
[ValidateScript({ Assert-CosmosDbDatabaseIdValid -Id $_ })]
[System.String]
$Id
)
if ($PSBoundParameters.ContainsKey('Id'))
{
$null = $PSBoundParameters.Remove('Id')
$result = Invoke-CosmosDbRequest @PSBoundParameters `
-Method 'Get' `
-ResourceType 'dbs' `
-ResourcePath ('dbs/{0}' -f $Id)
$database = ConvertFrom-Json -InputObject $result.Content
}
else
{
$result = Invoke-CosmosDbRequest @PSBoundParameters `
-Method 'Get' `
-ResourceType 'dbs'
$body = ConvertFrom-Json -InputObject $result.Content
$database = $body.Databases
}
if ($database)
{
return (Set-CosmosDbDatabaseType -Database $database)
}
}
I modified context as you suggested just before passing it to Get-CosmosDBDatabase as you suggested:
$context = @{
Account = $Name
Database = $DatabaseName
Key = (ConvertTo-SecureString $AccessKey -AsPlainText -Force)
}
$context = (New-CosmosDbContext @context)
$context.BaseUri = $ondSettings.static.documentDBAccount.uri
$existing = Get-CosmosDbDatabase -Context $context | Where-Object Id -eq $DatabaseName
I am now getting different error. Notice how the “dbs” added at the end of the name that I passed:
Account : lvinocosmose80016ecvus
Database : DocumentDatabase
Key : System.Security.SecureString
KeyType : master
BaseUri : https://lvinocosmose80016ecvus.documents.azure.us
Token :
BackoffPolicy :
[System.Net.WebException] The remote name could not be resolved: 'lvinocosmose80016ecvus.documents.azure.usdbs'
at Invoke-CosmosDbRequest, C:\Program Files\WindowsPowerShell\Modules\CosmosDB\2.1.15.239\CosmosDB.psm1: line 5217
at Get-CosmosDbDatabase, C:\Program Files\WindowsPowerShell\Modules\CosmosDB\2.1.15.239\CosmosDB.psm1: line 2008
at Publish-OndCosmosDbDatabase, C:\work\xcloud\core\deployment\scripts\bluegreen\Static\OndStaticCosmosDb.psm1: line 261
Is there anything else I can try?
Thanks again,
Lena
|
@PlagueHO , |
Issue
Please add parameterized support for Base URI 👍
documents.zure.us
https://docs.microsoft.com/en-us/azure/azure-government/documentation-government-services-database
The text was updated successfully, but these errors were encountered: