Skip to content

Commit 68a75f2

Browse files
authored
Merge pull request #10958 from MehaKaushik/master
CosmosDB Cassandra, Mongo, Table, Gremlin API with Management sdk 1.0.1
2 parents cf0bff8 + d2baefe commit 68a75f2

File tree

197 files changed

+21163
-1205
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

197 files changed

+21163
-1205
lines changed

ChangeLog.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
11
## 3.4.0 - February 2020
2+
3+
#### Az.CosmosDB
4+
* Added cmdlets for Gremlin, MongoDB, Cassandra and Table APIs.
5+
* Updated .NET SDK Version to 1.0.1
6+
* Added parameters ConflictResolutionPolicyMode, ConflictResolutionPolicyPath and ConflictResolutionPolicyPath in Set-AzCosmosDBSqlContainer.
7+
* Added new cmdlets for Sql API : New-CosmosDBSqlSpatialSpec, New-CosmosDBSqlCompositePath, New-CosmosDBSqlIncludedPathIndex, New-CosmosDBSqlIncludedPath
8+
29
### Highlights since the last major release
310
* Az.CosmosDB initial version 0.1.0 released
411
* Az.Network ConnectionMonitor V2 support added

src/CosmosDB/CosmosDB.Test/CosmosDB.Test.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@
44
</PropertyGroup>
55
<Import Project="$(MSBuildThisFileDirectory)..\..\Az.Test.props" />
66
<ItemGroup>
7-
<PackageReference Include="Microsoft.Azure.Management.CosmosDB" Version="1.0.0" />
7+
<PackageReference Include="Microsoft.Azure.Management.CosmosDB" Version="1.0.1" />
88
</ItemGroup>
99
</Project>
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
// ----------------------------------------------------------------------------------
2+
//
3+
// Copyright Microsoft Corporation
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
// Unless required by applicable law or agreed to in writing, software
9+
// distributed under the License is distributed on an "AS IS" BASIS,
10+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
// See the License for the specific language governing permissions and
12+
// limitations under the License.
13+
// ----------------------------------------------------------------------------------
14+
15+
using Microsoft.WindowsAzure.Commands.ScenarioTest;
16+
using Xunit;
17+
18+
namespace Microsoft.Azure.Commands.CosmosDB.Test.ScenarioTests.ScenarioTest
19+
{
20+
public class CassandraOperationsTests
21+
{
22+
private ServiceManagement.Common.Models.XunitTracingInterceptor _logger;
23+
24+
public CassandraOperationsTests(Xunit.Abstractions.ITestOutputHelper output)
25+
{
26+
_logger = new ServiceManagement.Common.Models.XunitTracingInterceptor(output);
27+
ServiceManagement.Common.Models.XunitTracingInterceptor.AddToContext(_logger);
28+
}
29+
30+
[Fact]
31+
[Trait(Category.AcceptanceType, Category.CheckIn)]
32+
public void TestCassandraOperationsCmdlets()
33+
{
34+
TestController.NewInstance.RunPowerShellTest(_logger, "Test-CassandraOperationsCmdlets");
35+
}
36+
37+
[Fact]
38+
[Trait(Category.AcceptanceType, Category.CheckIn)]
39+
public void TestCassandraOperationsCmdletsUsingInputObject()
40+
{
41+
TestController.NewInstance.RunPowerShellTest(_logger, "Test-CassandraOperationsCmdletsUsingInputObject");
42+
}
43+
}
44+
}
Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
# ----------------------------------------------------------------------------------
2+
#
3+
# Copyright Microsoft Corporation
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
# Unless required by applicable law or agreed to in writing, software
9+
# distributed under the License is distributed on an "AS IS" BASIS,
10+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
# See the License for the specific language governing permissions and
12+
# limitations under the License.
13+
# ----------------------------------------------------------------------------------
14+
<#
15+
.SYNOPSIS
16+
Gets and removes custom domain with running endpoint.
17+
#>
18+
19+
function Test-CassandraOperationsCmdlets
20+
{
21+
$AccountName = "db2725"
22+
$rgName = "CosmosDBResourceGroup2510"
23+
$KeyspaceName = "db"
24+
$TableName = "table"
25+
26+
$NewKeyspace = Set-AzCosmosDBCassandraKeyspace -AccountName $AccountName -ResourceGroupName $rgName -Name $KeyspaceName
27+
Assert-AreEqual $NewKeyspace.Name $KeyspaceName
28+
29+
$Column1 = New-AzCosmosDBCassandraColumn -Name "ColumnA" -Type "int"
30+
$Column2 = New-AzCosmosDBCassandraColumn -Name "ColumnB" -Type "ascii"
31+
32+
$clusterkey1 = New-AzCosmosDBCassandraClusterKey -Name "ColumnB" -OrderBy "Asc"
33+
$schema = New-AzCosmosDBCassandraSchema -Column $Column1,$Column2 -ClusterKey $clusterkey1 -PartitionKey "ColumnA"
34+
35+
$NewTable = Set-AzCosmosDBCassandraTable -AccountName $AccountName -ResourceGroupName $rgName -KeyspaceName $KeyspaceName -Name $TableName -Schema $schema
36+
Assert-AreEqual $NewTable.Name $TableName
37+
38+
$Keyspace = Get-AzCosmosDBCassandraKeyspace -AccountName $AccountName -ResourceGroupName $rgName -Name $KeyspaceName
39+
Assert-AreEqual $NewKeyspace.Id $Keyspace.Id
40+
Assert-AreEqual $NewKeyspace.Name $Keyspace.Name
41+
Assert-AreEqual $NewKeyspace.Resource.Id $Keyspace.Resource.Id
42+
Assert-AreEqual $NewKeyspace.Resource._rid $Keyspace.Resource._rid
43+
Assert-AreEqual $NewKeyspace.Resource._ts $Keyspace.Resource._ts
44+
Assert-AreEqual $NewKeyspace.Resource._etag $Keyspace.Resource._etag
45+
46+
$Table = Get-AzCosmosDBCassandraTable -AccountName $AccountName -ResourceGroupName $rgName -KeyspaceName $KeyspaceName -Name $TableName
47+
Assert-AreEqual $NewTable.Id $Table.Id
48+
Assert-AreEqual $NewTable.Name $Table.Name
49+
Assert-AreEqual $NewTable.Resource.Id $Table.Resource.Id
50+
Assert-AreEqual $NewTable.Resource._rid $Table.Resource._rid
51+
Assert-AreEqual $NewTable.Resource._ts $Table.Resource._ts
52+
Assert-AreEqual $NewTable.Resource._etag $Table.Resource._etag
53+
54+
$ListTables = Get-AzCosmosDBCassandraTable -AccountName $AccountName -ResourceGroupName $rgName -KeyspaceName $KeyspaceName
55+
Assert-NotNull($ListTables)
56+
57+
$ListKeyspaces = Get-AzCosmosDBCassandraKeyspace -AccountName $AccountName -ResourceGroupName $rgName
58+
Assert-NotNull($ListKeyspaces)
59+
60+
$IsTableRemoved = Remove-AzCosmosDBCassandraTable -AccountName $AccountName -ResourceGroupName $rgName -KeyspaceName $KeyspaceName -Name $TableName -PassThru
61+
Assert-AreEqual $IsTableRemoved true
62+
63+
$IsKeyspaceRemoved = Remove-AzCosmosDBCassandraKeyspace -AccountName $AccountName -ResourceGroupName $rgName -Name $KeyspaceName -PassThru
64+
Assert-AreEqual $IsKeyspaceRemoved true
65+
}
66+
67+
function Test-CassandraOperationsCmdletsUsingInputObject
68+
{
69+
$AccountName = "db2725"
70+
$rgName = "CosmosDBResourceGroup2510"
71+
$KeyspaceName = "db2"
72+
$TableName = "table"
73+
74+
$cosmosDBAccount = Get-AzCosmosDBAccount -ResourceGroupName $rgName -Name $AccountName
75+
76+
$NewKeyspace = Set-AzCosmosDBCassandraKeyspace -InputObject $cosmosDBAccount -Name $KeyspaceName
77+
Assert-AreEqual $NewKeyspace.Name $KeyspaceName
78+
79+
$Column1 = New-AzCosmosDBCassandraColumn -Name "ColumnA" -Type "int"
80+
$Column2 = New-AzCosmosDBCassandraColumn -Name "ColumnB" -Type "ascii"
81+
$clusterkey1 = New-AzCosmosDBCassandraClusterKey -Name "ColumnB" -OrderBy "Asc"
82+
$schema = New-AzCosmosDBCassandraSchema -Column $Column1,$Column2 -ClusterKey $clusterkey1 -PartitionKey "ColumnA"
83+
84+
$NewTable = Set-AzCosmosDBCassandraTable -InputObject $NewKeyspace -Name $TableName -Schema $schema
85+
Assert-AreEqual $NewTable.Name $TableName
86+
87+
$Keyspace = Get-AzCosmosDBCassandraKeyspace -InputObject $cosmosDBAccount -Name $KeyspaceName
88+
Assert-AreEqual $NewKeyspace.Id $Keyspace.Id
89+
Assert-AreEqual $NewKeyspace.Name $Keyspace.Name
90+
Assert-AreEqual $NewKeyspace.Resource.Id $Keyspace.Resource.Id
91+
Assert-AreEqual $NewKeyspace.Resource._rid $Keyspace.Resource._rid
92+
Assert-AreEqual $NewKeyspace.Resource._ts $Keyspace.Resource._ts
93+
Assert-AreEqual $NewKeyspace.Resource._etag $Keyspace.Resource._etag
94+
95+
$Table = Get-AzCosmosDBCassandraTable -InputObject $NewKeyspace -Name $TableName
96+
Assert-AreEqual $NewTable.Id $Table.Id
97+
Assert-AreEqual $NewTable.Name $Table.Name
98+
Assert-AreEqual $NewTable.Resource.Id $Table.Resource.Id
99+
Assert-AreEqual $NewTable.Resource._rid $Table.Resource._rid
100+
Assert-AreEqual $NewTable.Resource._ts $Table.Resource._ts
101+
Assert-AreEqual $NewTable.Resource._etag $Table.Resource._etag
102+
103+
$ListTables = Get-AzCosmosDBCassandraTable -InputObject $NewKeyspace
104+
Assert-NotNull($ListTables)
105+
106+
$ListKeyspaces = Get-AzCosmosDBCassandraKeyspace -InputObject $cosmosDBAccount
107+
Assert-NotNull($ListKeyspaces)
108+
109+
$IsTableRemoved = Remove-AzCosmosDBCassandraTable -InputObject $NewTable -PassThru
110+
Assert-AreEqual $IsTableRemoved true
111+
112+
$IsKeyspaceRemoved = Remove-AzCosmosDBCassandraKeyspace -InputObject $NewKeyspace -PassThru
113+
Assert-AreEqual $IsKeyspaceRemoved true
114+
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
// ----------------------------------------------------------------------------------
2+
//
3+
// Copyright Microsoft Corporation
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
// Unless required by applicable law or agreed to in writing, software
9+
// distributed under the License is distributed on an "AS IS" BASIS,
10+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
// See the License for the specific language governing permissions and
12+
// limitations under the License.
13+
// ----------------------------------------------------------------------------------
14+
15+
using Microsoft.WindowsAzure.Commands.ScenarioTest;
16+
using Xunit;
17+
18+
namespace Microsoft.Azure.Commands.CosmosDB.Test.ScenarioTests.ScenarioTest
19+
{
20+
public class GremlinOperationsTests
21+
{
22+
private ServiceManagement.Common.Models.XunitTracingInterceptor _logger;
23+
24+
public GremlinOperationsTests(Xunit.Abstractions.ITestOutputHelper output)
25+
{
26+
_logger = new ServiceManagement.Common.Models.XunitTracingInterceptor(output);
27+
ServiceManagement.Common.Models.XunitTracingInterceptor.AddToContext(_logger);
28+
}
29+
30+
[Fact]
31+
[Trait(Category.AcceptanceType, Category.CheckIn)]
32+
public void TestGremlinOperationsCmdlets()
33+
{
34+
TestController.NewInstance.RunPowerShellTest(_logger, "Test-GremlinOperationsCmdlets");
35+
}
36+
37+
[Fact]
38+
[Trait(Category.AcceptanceType, Category.CheckIn)]
39+
public void TestGremlinOperationsCmdletsUsingInputObject()
40+
{
41+
TestController.NewInstance.RunPowerShellTest(_logger, "Test-GremlinOperationsCmdletsUsingInputObject");
42+
}
43+
}
44+
}
Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
# ----------------------------------------------------------------------------------
2+
#
3+
# Copyright Microsoft Corporation
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
# Unless required by applicable law or agreed to in writing, software
9+
# distributed under the License is distributed on an "AS IS" BASIS,
10+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
# See the License for the specific language governing permissions and
12+
# limitations under the License.
13+
# ----------------------------------------------------------------------------------
14+
<#
15+
.SYNOPSIS
16+
Gets and removes custom domain with running endpoint.
17+
#>
18+
19+
function Test-GremlinOperationsCmdlets
20+
{
21+
$AccountName = "db1002"
22+
$rgName = "CosmosDBResourceGroup2510"
23+
$DatabaseName = "dbName"
24+
$GraphName = "graph1"
25+
26+
$PartitionKeyPathValue = "/foo"
27+
$PartitionKeyKindValue = "Hash"
28+
29+
$NewDatabase = Set-AzCosmosDBGremlinDatabase -AccountName $AccountName -ResourceGroupName $rgName -Name $DatabaseName
30+
Assert-AreEqual $NewDatabase.Name $DatabaseName
31+
32+
#Indexing Policy Creation
33+
$ipath1 = New-AzCosmosDBGremlinIncludedPathIndex -DataType String -Precision -1 -Kind Hash
34+
$ipath2 = New-AzCosmosDBGremlinIncludedPathIndex -DataType String -Precision -1 -Kind Hash
35+
$IncludedPath = New-AzCosmosDBGremlinIncludedPath -Path "/*" -Index $ipath1, $ipath2
36+
$SpatialSpec = New-AzCosmosDBGremlinSpatialSpec -Path "/mySpatialPath/*" -Type "Point", "LineString", "Polygon", "MultiPolygon"
37+
$cp1 = New-AzCosmosDBGremlinCompositePath -Path "/abc" -Order Ascending
38+
$cp2 = New-AzCosmosDBGremlinCompositePath -Path "/aberc" -Order Descending
39+
$CompositePaths = (($cp1, $cp2), ($cp2, $cp1))
40+
41+
$IndexingPolicy = New-AzCosmosDBGremlinIndexingPolicy -IncludedPath $IncludedPath -SpatialSpec $SpatialSpec -CompositePath $CompositePaths -ExcludedPath "/myPathToNotIndex/*" -Automatic 1 -IndexingMode Consistent
42+
43+
#UniqueKey Creation
44+
$p1 = New-AzCosmosDBGremlinUniqueKey -Path "/myUniqueKey3"
45+
$p2 = New-AzCosmosDBGremlinUniqueKey -Path "/myUniqueKey4"
46+
$p3 = New-AzCosmosDBGremlinUniqueKey -Path "/myUniqueKey2"
47+
$p4 = New-AzCosmosDBGremlinUniqueKey -Path "/myUniqueKey1"
48+
49+
$uk1 = New-AzCosmosDBGremlinUniqueKeyPolicy -UniqueKey $p1,$p2,$p3,$p4
50+
51+
$NewGraph = Set-AzCosmosDBGremlinGraph -AccountName $AccountName -ResourceGroupName $rgName -DatabaseName $DatabaseName -Name $GraphName -PartitionKeyPath $PartitionKeyPathValue -PartitionKeyKind $PartitionKeyKindValue -IndexingPolicy $IndexingPolicy -UniqueKeyPolicy $uk1
52+
Assert-AreEqual $NewGraph.Name $GraphName
53+
Assert-AreEqual $NewGraph.Resource.IndexingPolicy.Automatic $IndexingPolicy.Automatic
54+
Assert-AreEqual $NewGraph.Resource.IndexingPolicy.IndexingMode $IndexingPolicy.IndexingMode
55+
Assert-AreEqual $NewGraph.Resource.IndexingPolicy.IncludedPath.Path $IndexingPolicy.IncludedPath.Path
56+
Assert-AreEqual $NewGraph.Resource.IndexingPolicy.CompositeIndexes.Count 2
57+
Assert-AreEqual $NewGraph.Resource.IndexingPolicy.SpatialIndexes.Path $SpatialSpec.Path
58+
Assert-AreEqual $NewGraph.Resource.UniqueKeyPolicy.UniqueKeys.Count 4
59+
60+
$Database = Get-AzCosmosDBGremlinDatabase -AccountName $AccountName -ResourceGroupName $rgName -Name $DatabaseName
61+
Assert-AreEqual $NewDatabase.Id $Database.Id
62+
Assert-AreEqual $NewDatabase.Name $Database.Name
63+
Assert-AreEqual $NewDatabase.Resource.Id $Database.Resource.Id
64+
Assert-AreEqual $NewDatabase.Resource._rid $Database.Resource._rid
65+
Assert-AreEqual $NewDatabase.Resource._ts $Database.Resource._ts
66+
Assert-AreEqual $NewDatabase.Resource._etag $Database.Resource._etag
67+
68+
$Graph = Get-AzCosmosDBGremlinGraph -AccountName $AccountName -ResourceGroupName $rgName -DatabaseName $DatabaseName -Name $GraphName
69+
Assert-AreEqual $NewGraph.Id $Graph.Id
70+
Assert-AreEqual $NewGraph.Name $Graph.Name
71+
Assert-AreEqual $NewGraph.GremlinGraphGetResultsId $Graph.GremlinGraphGetResultsId
72+
Assert-AreEqual $NewGraph._rid $Graph._rid
73+
Assert-AreEqual $NewGraph._ts $Graph._ts
74+
Assert-AreEqual $NewGraph._etag $Graph._etag
75+
76+
$ListGraphs = Get-AzCosmosDBGremlinGraph -AccountName $AccountName -ResourceGroupName $rgName -DatabaseName $DatabaseName
77+
Assert-NotNull($ListGraphs)
78+
79+
$ListDatabases = Get-AzCosmosDBGremlinDatabase -AccountName $AccountName -ResourceGroupName $rgName
80+
Assert-NotNull($ListDatabases)
81+
82+
$IsGraphRemoved = Remove-AzCosmosDBGremlinGraph -AccountName $AccountName -ResourceGroupName $rgName -DatabaseName $DatabaseName -Name $GraphName -PassThru
83+
Assert-AreEqual $IsGraphRemoved true
84+
85+
$IsDatabaseRemoved = Remove-AzCosmosDBGremlinDatabase -AccountName $AccountName -ResourceGroupName $rgName -Name $DatabaseName -PassThru
86+
Assert-AreEqual $IsDatabaseRemoved true
87+
}
88+
89+
function Test-GremlinOperationsCmdletsUsingInputObject
90+
{
91+
$AccountName = "db1002"
92+
$rgName = "CosmosDBResourceGroup2510"
93+
$DatabaseName = "dbName2"
94+
$GraphName = "graph1"
95+
96+
$PartitionKeyPathValue = "/foo"
97+
$PartitionKeyKindValue = "Hash"
98+
99+
$cosmosDBAccount = Get-AzCosmosDBAccount -ResourceGroupName $rgName -Name $AccountName
100+
101+
$NewDatabase = Set-AzCosmosDBGremlinDatabase -InputObject $cosmosDBAccount -Name $DatabaseName
102+
Assert-AreEqual $NewDatabase.Name $DatabaseName
103+
104+
$NewGraph = Set-AzCosmosDBGremlinGraph -InputObject $NewDatabase -Name $GraphName -PartitionKeyPath $PartitionKeyPathValue -PartitionKeyKind $PartitionKeyKindValue
105+
Assert-AreEqual $NewGraph.Name $GraphName
106+
107+
$Database = Get-AzCosmosDBGremlinDatabase -InputObject $cosmosDBAccount -Name $DatabaseName
108+
Assert-AreEqual $NewDatabase.Id $Database.Id
109+
Assert-AreEqual $NewDatabase.Name $Database.Name
110+
Assert-AreEqual $NewDatabase.Resource.Id $Database.Resource.Id
111+
Assert-AreEqual $NewDatabase.Resource._rid $Database.Resource._rid
112+
Assert-AreEqual $NewDatabase.Resource._ts $Database.Resource._ts
113+
Assert-AreEqual $NewDatabase.Resource._etag $Database.Resource._etag
114+
115+
$Graph = Get-AzCosmosDBGremlinGraph -InputObject $NewDatabase -Name $GraphName
116+
Assert-AreEqual $NewGraph.Id $Graph.Id
117+
Assert-AreEqual $NewGraph.Name $Graph.Name
118+
Assert-AreEqual $NewGraph.Resource.Id $Graph.Resource.Id
119+
Assert-AreEqual $NewGraph.Resource._rid $Graph.Resource._rid
120+
Assert-AreEqual $NewGraph.Resource._ts $Graph.Resource._ts
121+
Assert-AreEqual $NewGraph.Resource._etag $Graph.Resource._etag
122+
123+
$ListGraphs = Get-AzCosmosDBGremlinGraph -InputObject $NewDatabase
124+
Assert-NotNull($ListGraphs)
125+
126+
$ListDatabases = Get-AzCosmosDBGremlinDatabase -InputObject $cosmosDBAccount
127+
Assert-NotNull($ListDatabases)
128+
129+
$IsGraphRemoved = Remove-AzCosmosDBGremlinGraph -InputObject $NewGraph -PassThru
130+
Assert-AreEqual $IsGraphRemoved true
131+
132+
$IsDatabaseRemoved = Remove-AzCosmosDBGremlinDatabase -InputObject $NewDatabase -PassThru
133+
Assert-AreEqual $IsDatabaseRemoved true
134+
}

0 commit comments

Comments
 (0)