Skip to content

Commit

Permalink
Cosmos DB: Update to 2.0.0 and Add support for NetworkAclBypass in Ac…
Browse files Browse the repository at this point in the history
…count (#14211)

* Make changes for Network Acl Bypass

* Add help file updates

* Changes with enum not as string

* rerun tests

* Remove extra line

* rerun gremlin test with updated

* Update ChangeLog.md

Co-authored-by: Yabo Hu <yabhu@microsoft.com>
  • Loading branch information
kristynhamasaki and VeryEarly authored Feb 19, 2021
1 parent 24bd84a commit c1a7cbe
Show file tree
Hide file tree
Showing 38 changed files with 158,414 additions and 20,138 deletions.
2 changes: 1 addition & 1 deletion src/CosmosDB/CosmosDB.Test/CosmosDB.Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
<Import Project="$(MSBuildThisFileDirectory)..\..\Az.Test.props" />
<ItemGroup>
<PackageReference Include="Microsoft.Azure.Management.Network" Version="20.3.0" />
<PackageReference Include="Microsoft.Azure.Management.CosmosDB" Version="1.2.1" />
<PackageReference Include="Microsoft.Azure.Management.CosmosDB" Version="2.0.0" />
</ItemGroup>
</Project>
12 changes: 9 additions & 3 deletions src/CosmosDB/CosmosDB.Test/ScenarioTests/AccountTests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,16 @@ function Test-AccountRelatedCmdlets
$cosmosDBAccountName = "cosmosdb67"

#use an existing account with the following information for Account Update Operations
$cosmosDBExistingAccountName = "dbaccount27"
$cosmosDBExistingAccountName = "dbaccount30"
$existingResourceGroupName = "CosmosDBResourceGroup27"

$IpRule = "201.168.50.1"
$tags = @{ name = "test"; Shape = "Square"; Color = "Blue"}
$publicNetworkAccess = "Enabled"
$networkAclBypass = "AzureServices"
$networkAclBypassResourceId = "/subscriptions/subId/resourcegroups/rgName/providers/Microsoft.Synapse/workspaces/workspaceName"

$cosmosDBAccount = New-AzCosmosDBAccount -ResourceGroupName $rgName -Name $cosmosDBAccountName -DefaultConsistencyLevel "BoundedStaleness" -MaxStalenessIntervalInSeconds 10 -MaxStalenessPrefix 20 -Location $location -IpRule $IpRule -Tag $tags -EnableVirtualNetwork -EnableMultipleWriteLocations -EnableAutomaticFailover -ApiKind "MongoDB" -PublicNetworkAccess $publicNetworkAccess -EnableFreeTier 0 -EnableAnalyticalStorage 0 -ServerVersion "3.2"
$cosmosDBAccount = New-AzCosmosDBAccount -ResourceGroupName $rgName -Name $cosmosDBAccountName -DefaultConsistencyLevel "BoundedStaleness" -MaxStalenessIntervalInSeconds 10 -MaxStalenessPrefix 20 -Location $location -IpRule $IpRule -Tag $tags -EnableVirtualNetwork -EnableMultipleWriteLocations -EnableAutomaticFailover -ApiKind "MongoDB" -PublicNetworkAccess $publicNetworkAccess -EnableFreeTier 0 -EnableAnalyticalStorage 0 -ServerVersion "3.2" -NetworkAclBypass $NetworkAclBypass

Assert-AreEqual $cosmosDBAccountName $cosmosDBAccount.Name
Assert-AreEqual "BoundedStaleness" $cosmosDBAccount.ConsistencyPolicy.DefaultConsistencyLevel
Expand All @@ -45,6 +47,8 @@ function Test-AccountRelatedCmdlets
Assert-AreEqual $cosmosDBAccount.ApiProperties.ServerVersion "3.2"
Assert-AreEqual $cosmosDBAccount.EnableAnalyticalStorage 0
Assert-AreEqual $cosmosDBAccount.EnableFreeTier 0
Assert-AreEqual $cosmosDBAccount.NetworkAclBypass $NetworkAclBypass
Assert-AreEqual $cosmosDBAccount.NetworkAclBypassResourceIds.Count 0

# create an existing database
Try {
Expand All @@ -54,7 +58,7 @@ function Test-AccountRelatedCmdlets
Assert-AreEqual $_.Exception.Message ("Resource with Name " + $cosmosDBAccountName + " already exists.")
}

$updatedCosmosDBAccount = Update-AzCosmosDBAccount -ResourceGroupName $existingResourceGroupName -Name $cosmosDBExistingAccountName -DefaultConsistencyLevel "BoundedStaleness" -MaxStalenessIntervalInSeconds 10 -MaxStalenessPrefix 20 -IpRule $IpRule -Tag $tags -EnableVirtualNetwork 1 -EnableAutomaticFailover 1 -PublicNetworkAccess $publicNetworkAccess
$updatedCosmosDBAccount = Update-AzCosmosDBAccount -ResourceGroupName $existingResourceGroupName -Name $cosmosDBExistingAccountName -DefaultConsistencyLevel "BoundedStaleness" -MaxStalenessIntervalInSeconds 10 -MaxStalenessPrefix 20 -IpRule $IpRule -Tag $tags -EnableVirtualNetwork 1 -EnableAutomaticFailover 1 -PublicNetworkAccess $publicNetworkAccess -NetworkAclBypass $NetworkAclBypass -NetworkAclBypassResourceId $networkAclBypassResourceId

Assert-AreEqual $cosmosDBExistingAccountName $updatedCosmosDBAccount.Name
Assert-AreEqual "BoundedStaleness" $updatedCosmosDBAccount.ConsistencyPolicy.DefaultConsistencyLevel
Expand All @@ -63,6 +67,8 @@ function Test-AccountRelatedCmdlets
Assert-AreEqual $updatedCosmosDBAccount.EnableAutomaticFailover 1
Assert-AreEqual $updatedCosmosDBAccount.IsVirtualNetworkFilterEnabled 1
Assert-AreEqual $updatedCosmosDBAccount.PublicNetworkAccess $publicNetworkAccess
Assert-AreEqual $updatedCosmosDBAccount.NetworkAclBypass $NetworkAclBypass
Assert-AreEqual $updatedCosmosDBAccount.NetworkAclBypassResourceIds.Count 1

$cosmosDBAccountKey = Get-AzCosmosDBAccountKey -Name $cosmosDBAccountName -ResourceGroupName $rgname
Assert-NotNull $cosmosDBAccountKey
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ function Test-GremlinOperationsCmdlets
$DatabaseName = "dbName"
$graphName = "graph1"

$DatabaseName2 = "dbName2"
$DatabaseName2 = "dbName29"
$graphName2 = "graph2"

$PartitionKeyPathValue = "/foo"
Expand Down Expand Up @@ -254,7 +254,7 @@ function Test-GremlinThroughputCmdlets
{
$AccountName = "db1002"
$rgName = "CosmosDBResourceGroup2510"
$DatabaseName = "dbName3"
$DatabaseName = "dbName30"
$GraphName = "graphName"

$PartitionKeyPathValue = "/foo"
Expand Down
Loading

0 comments on commit c1a7cbe

Please sign in to comment.