Skip to content
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion src/CosmosDB/CosmosDB.Test/ScenarioTests/AccountTests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,17 @@ function Test-AccountRelatedCmdlets
Assert-NotNull $cosmosDBAccountKey

$cosmosDBAccountConnectionStrings = Get-AzCosmosDBAccountKey -Name $cosmosDBAccountName -ResourceGroupName $rgname -Type "ConnectionStrings"
Write-Output $cosmosDBAccountConnectionStrings
Assert-NotNull $cosmosDBAccountConnectionStrings

for (($i = 0); $i -lt $cosmosDBAccountConnectionStrings.Count; $i++) {
Assert-NotNull $cosmosDBAccountConnectionStrings[$i].KeyKind
Assert-NotNull $cosmosDBAccountConnectionStrings[$i].Type
}

$cosmosDBAccountReadOnlyKeys = Get-AzCosmosDBAccountKey -Name $cosmosDBAccountName -ResourceGroupName $rgname -Type "ReadOnlyKeys"
Assert-NotNull $cosmosDBAccountReadOnlyKeys
Assert-NotNull $cosmosDBAccountReadOnlyKeys["PrimaryReadonlyMasterKey"]
Assert-NotNull $cosmosDBAccountReadOnlyKeys["SecondaryReadonlyMasterKey"]

$RegeneratedKey = New-AzCosmosDBAccountKey -Name $cosmosDBAccountName -ResourceGroupName $rgname -KeyKind "primary"
Assert-NotNull $RegeneratedKey
Expand Down Expand Up @@ -343,6 +350,9 @@ function Test-CosmosDBLocations {
Assert-NotNull $locationProperty.Properties.SupportsAvailabilityZone
Assert-NotNull $locationProperty.Properties.IsResidencyRestricted
Assert-NotNull $locationProperty.Properties.BackupStorageRedundancies
Assert-NotNull $locationProperty.Properties.IsSubscriptionRegionAccessAllowedForRegular
Assert-NotNull $locationProperty.Properties.IsSubscriptionRegionAccessAllowedForAz
Assert-NotNull $locationProperty.Properties.Status
}

$locationProperties = Get-AzCosmosDBLocation -Location $locationName
Expand All @@ -352,4 +362,7 @@ function Test-CosmosDBLocations {
Assert-NotNull $locationProperties.Properties.SupportsAvailabilityZone
Assert-NotNull $locationProperties.Properties.IsResidencyRestricted
Assert-NotNull $locationProperties.Properties.BackupStorageRedundancies
Assert-NotNull $locationProperty.Properties.IsSubscriptionRegionAccessAllowedForRegular
Assert-NotNull $locationProperty.Properties.IsSubscriptionRegionAccessAllowedForAz
Assert-NotNull $locationProperty.Properties.Status
}
4 changes: 2 additions & 2 deletions src/CosmosDB/CosmosDB.Test/ScenarioTests/RestoreTests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -649,7 +649,7 @@ function Test-TableBackupInformationCmdLets {

function Test-UpdateCosmosDBAccountBackupPolicyToContinuous30DaysCmdLets {
$rgName = "PSCosmosDBResourceGroup20"
$location = "Central US"
$location = "East US"
$cosmosDBAccountName = "ps-cosmosdb-1220"
$apiKind = "Sql"
$consistencyLevel = "Session"
Expand Down Expand Up @@ -682,7 +682,7 @@ function Test-UpdateCosmosDBAccountBackupPolicyToContinuous30DaysCmdLets {

function Test-UpdateCosmosDBAccountBackupPolicyToContinuous7DaysCmdLets {
$rgName = "PSCosmosDBResourceGroup50"
$location = "Central US"
$location = "East US"
$cosmosDBAccountName = "ps-cosmosdb-1250"
$apiKind = "Sql"
$consistencyLevel = "Session"
Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions src/CosmosDB/CosmosDB/ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
-->

## Upcoming Release
* ListConnectionStrings response now includes keyKind and type properties
* Locations show response now includes status, isSubscriptionRegionAccessAllowedForRegular and isSubscriptionRegionAccessAllowedForAz properties

## Version 1.11.0
* Added support for Continuous 7 Days backup mode.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,19 @@

using System;
using System.Collections;
using System.Collections.Generic;
using System.Management.Automation;
using Microsoft.Azure.Commands.CosmosDB.Helpers;
using Microsoft.Azure.Commands.CosmosDB.Models;
using Microsoft.Azure.Commands.ResourceManager.Common.ArgumentCompleters;
using Microsoft.Azure.Management.CosmosDB.Models;
using Microsoft.Azure.Management.Internal.Resources.Utilities.Models;
using Microsoft.WindowsAzure.Commands.Common.CustomAttributes;

namespace Microsoft.Azure.Commands.CosmosDB
{
[Cmdlet(VerbsCommon.Get, ResourceManager.Common.AzureRMConstants.AzureRMPrefix + "CosmosDBAccountKey", DefaultParameterSetName = NameParameterSet), OutputType(typeof(Hashtable))]
[GenericBreakingChange("Output type for -Type ConnectionStrings has been changed to List<DatabaseAccountConnectionString>")]
[Cmdlet(VerbsCommon.Get, ResourceManager.Common.AzureRMConstants.AzureRMPrefix + "CosmosDBAccountKey", DefaultParameterSetName = NameParameterSet), OutputType(typeof(Hashtable), typeof(IList<DatabaseAccountConnectionString>))]
public class GetAzCosmosDBAccountKey : AzureCosmosDBCmdletBase
{
[Parameter(Mandatory = true, ParameterSetName = NameParameterSet, HelpMessage = Constants.ResourceGroupNameHelpMessage)]
Expand Down Expand Up @@ -69,7 +72,7 @@ public override void ExecuteCmdlet()
if (Type.Equals("ConnectionStrings", StringComparison.OrdinalIgnoreCase))
{
DatabaseAccountListConnectionStringsResult response = CosmosDBManagementClient.DatabaseAccounts.ListConnectionStringsWithHttpMessagesAsync(ResourceGroupName, Name).GetAwaiter().GetResult().Body;
WriteObject(new PSDatabaseAccountListKeys(response).Keys);
WriteObject(new PSDatabaseAccountListKeys(response).ConnectionStrings);
}
else if (Type.Equals("ReadOnlyKeys", StringComparison.OrdinalIgnoreCase))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
namespace Microsoft.Azure.Commands.CosmosDB.Models
{
using System.Collections;
using System.Collections.Generic;
using Microsoft.Azure.Management.CosmosDB.Models;

public class PSDatabaseAccountListKeys
Expand Down Expand Up @@ -43,7 +44,7 @@ public PSDatabaseAccountListKeys(DatabaseAccountListConnectionStringsResult data

foreach (DatabaseAccountConnectionString connectionString in databaseAccountConnectionString.ConnectionStrings)
{
Keys.Add(connectionString.Description, connectionString.ConnectionString);
ConnectionStrings.Add(connectionString);
}
}

Expand All @@ -61,5 +62,7 @@ public PSDatabaseAccountListKeys(DatabaseAccountListKeysResult databaseAccountLi
}

public Hashtable Keys { get; set; } = new Hashtable();

public IList<DatabaseAccountConnectionString> ConnectionStrings { get; set; } = new List<DatabaseAccountConnectionString>();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ public PSLocationProperties(LocationProperties locationProperties)
SupportsAvailabilityZone = locationProperties.SupportsAvailabilityZone;
IsResidencyRestricted = locationProperties.IsResidencyRestricted;
BackupStorageRedundancies = locationProperties.BackupStorageRedundancies;
IsSubscriptionRegionAccessAllowedForRegular = locationProperties.IsSubscriptionRegionAccessAllowedForRegular;
IsSubscriptionRegionAccessAllowedForAz = locationProperties.IsSubscriptionRegionAccessAllowedForAz;
Status = locationProperties.Status;
}

/// <summary>
Expand All @@ -49,5 +52,24 @@ public PSLocationProperties(LocationProperties locationProperties)
/// Gets the properties of available backup storage redundancies.
/// </summary>
public IList<string> BackupStorageRedundancies { get; set; }

/// <summary>
/// Gets flag indicating whether the subscription have access in region
/// for Non-Availability Zones.
/// </summary>
public bool? IsSubscriptionRegionAccessAllowedForRegular { get; set; }

/// <summary>
/// Gets flag indicating whether the subscription have access in region
/// for Availability Zones(Az).
/// </summary>
public bool? IsSubscriptionRegionAccessAllowedForAz { get; set; }

/// <summary>
/// Gets enum to indicate current buildout status of the region.
/// Possible values include: 'Uninitialized', 'Initializing',
/// 'InternallyReady', 'Online', 'Deleting'
/// </summary>
public string Status { get; set; }
}
}
16 changes: 16 additions & 0 deletions src/CosmosDB/CosmosDB/help/Get-AzCosmosDBAccountKey.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,22 @@ SecondaryReadonlyMasterKey 9YRcTABuOHcKyHAKf0lmCeHsrcXu02aeID1g3wjXjlX8SU4s2

Lists the keys for CosmosDB Account. The Key Type can be value from : ConnectionStrings, Keys and ReadOnlyKeys. Default is Keys.

### Example 2
```powershell
Get-AzCosmosDBAccountKey -ResourceGroupName rg1 -Name dbname -Type "ConnectionStrings"
```

```output
ConnectionString Description KeyKind Type
---------------- ----------- ------- ----
AccountEndpoint=https://cosmosdbaccount.documents.azure.com:443/;AccountKey=qjw0ISW1WNN0BIVPeaI7Tm3H8uZ1h7ESQjxaUendxHmIUNQowVvcL84fTqeXoC2HFgyu8Zo1mCFEcg0jZJHPjA==; Primary SQL Connection String Primary Sql
AccountEndpoint=https://cosmosdbaccount.documents.azure.com:443/;AccountKey=qjw0ISW1WNN0BIVPeaI7Tm3H8uZ1h7ESQjxaUendxHmIUNQowVvcL84fTqeXoC2HFgyu8Zo1mCFEcg0jZJHPjA==; Secondary SQL Connection String Secondary Sql
AccountEndpoint=https://cosmosdbaccount.documents.azure.com:443/;AccountKey=qjw0ISW1WNN0BIVPeaI7Tm3H8uZ1h7ESQjxaUendxHmIUNQowVvcL84fTqeXoC2HFgyu8Zo1mCFEcg0jZJHPjA==; Primary Read-Only SQL Connection String PrimaryReadonly Sql
AccountEndpoint=https://cosmosdbaccount.documents.azure.com:443/;AccountKey=qjw0ISW1WNN0BIVPeaI7Tm3H8uZ1h7ESQjxaUendxHmIUNQowVvcL84fTqeXoC2HFgyu8Zo1mCFEcg0jZJHPjA==; Secondary Read-Only SQL Connection String SecondaryReadonly Sql
```

Lists the ConnectionStrings for CosmosDB Account by specifying Key Type ConnectionStrings.

## PARAMETERS

### -DefaultProfile
Expand Down
22 changes: 17 additions & 5 deletions src/CosmosDB/CosmosDB/help/Get-AzCosmosDBLocation.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Get-AzCosmosDBLocation [-Location <String>] [-DefaultProfile <IAzureContextConta
```

## DESCRIPTION
List Azure Cosmos DB locations with their location properties. It includes Location Id, Name, Type, SupportsAvailabilityZone, IsResidencyRestricted and BackupStorageRedundancies.
List Azure Cosmos DB locations with their location properties. It includes Location Id, Name, Type, SupportsAvailabilityZone, IsResidencyRestricted, BackupStorageRedundancies, IsSubscriptionRegionAccessAllowedForRegular, IsSubscriptionRegionAccessAllowedForAz and Status.

## EXAMPLES

Expand All @@ -44,7 +44,10 @@ Get-AzCosmosDBLocation -Location "Central US" | ConvertTo-Json
"Geo",
"Zone",
"Local"
]
],
"IsSubscriptionRegionAccessAllowedForRegular": true,
"IsSubscriptionRegionAccessAllowedForAz": false,
"Status": "Online"
}
}
```
Expand All @@ -70,7 +73,10 @@ Get-AzCosmosDBLocation | ConvertTo-Json
"Properties": {
"SupportsAvailabilityZone": true,
"IsResidencyRestricted": false,
"BackupStorageRedundancies": "Geo Local"
"BackupStorageRedundancies": "Geo Local",
"IsSubscriptionRegionAccessAllowedForRegular": true,
"IsSubscriptionRegionAccessAllowedForAz": false,
"Status": "Online"
}
},
{
Expand All @@ -80,7 +86,10 @@ Get-AzCosmosDBLocation | ConvertTo-Json
"Properties": {
"SupportsAvailabilityZone": true,
"IsResidencyRestricted": false,
"BackupStorageRedundancies": "Geo Zone Local"
"BackupStorageRedundancies": "Geo Zone Local",
"IsSubscriptionRegionAccessAllowedForRegular": false,
"IsSubscriptionRegionAccessAllowedForAz": true,
"Status": "Online"
}
},
{
Expand All @@ -90,7 +99,10 @@ Get-AzCosmosDBLocation | ConvertTo-Json
"Properties": {
"SupportsAvailabilityZone": false,
"IsResidencyRestricted": false,
"BackupStorageRedundancies": "Geo Local"
"BackupStorageRedundancies": "Geo Local",
"IsSubscriptionRegionAccessAllowedForRegular": true,
"IsSubscriptionRegionAccessAllowedForAz": true,
"Status": "Online"
}
}
]
Expand Down