Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
7 changes: 7 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
## 3.4.0 - February 2020

#### Az.CosmosDB
* Added cmdlets for Gremlin, MongoDB, Cassandra and Table APIs.
* Updated .NET SDK Version to 1.0.1
* Added parameters ConflictResolutionPolicyMode, ConflictResolutionPolicyPath and ConflictResolutionPolicyPath in Set-AzCosmosDBSqlContainer.
* Added new cmdlets for Sql API : New-CosmosDBSqlSpatialSpec, New-CosmosDBSqlCompositePath, New-CosmosDBSqlIncludedPathIndex, New-CosmosDBSqlIncludedPath

### Highlights since the last major release
* Az.CosmosDB initial version 0.1.0 released
* Az.Network ConnectionMonitor V2 support added
Expand Down
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 @@ -4,6 +4,6 @@
</PropertyGroup>
<Import Project="$(MSBuildThisFileDirectory)..\..\Az.Test.props" />
<ItemGroup>
<PackageReference Include="Microsoft.Azure.Management.CosmosDB" Version="1.0.0" />
<PackageReference Include="Microsoft.Azure.Management.CosmosDB" Version="1.0.1" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// ----------------------------------------------------------------------------------
//
// Copyright Microsoft Corporation
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// ----------------------------------------------------------------------------------

using Microsoft.WindowsAzure.Commands.ScenarioTest;
using Xunit;

namespace Microsoft.Azure.Commands.CosmosDB.Test.ScenarioTests.ScenarioTest
{
public class CassandraOperationsTests
{
private ServiceManagement.Common.Models.XunitTracingInterceptor _logger;

public CassandraOperationsTests(Xunit.Abstractions.ITestOutputHelper output)
{
_logger = new ServiceManagement.Common.Models.XunitTracingInterceptor(output);
ServiceManagement.Common.Models.XunitTracingInterceptor.AddToContext(_logger);
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestCassandraOperationsCmdlets()
{
TestController.NewInstance.RunPowerShellTest(_logger, "Test-CassandraOperationsCmdlets");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestCassandraOperationsCmdletsUsingInputObject()
{
TestController.NewInstance.RunPowerShellTest(_logger, "Test-CassandraOperationsCmdletsUsingInputObject");
}
}
}
114 changes: 114 additions & 0 deletions src/CosmosDB/CosmosDB.Test/ScenarioTests/CassandraOperationsTests.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
# ----------------------------------------------------------------------------------
#
# Copyright Microsoft Corporation
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ----------------------------------------------------------------------------------
<#
.SYNOPSIS
Gets and removes custom domain with running endpoint.
#>

function Test-CassandraOperationsCmdlets
{
$AccountName = "db2725"
$rgName = "CosmosDBResourceGroup2510"
$KeyspaceName = "db"
$TableName = "table"

$NewKeyspace = Set-AzCosmosDBCassandraKeyspace -AccountName $AccountName -ResourceGroupName $rgName -Name $KeyspaceName
Assert-AreEqual $NewKeyspace.Name $KeyspaceName

$Column1 = New-AzCosmosDBCassandraColumn -Name "ColumnA" -Type "int"
$Column2 = New-AzCosmosDBCassandraColumn -Name "ColumnB" -Type "ascii"

$clusterkey1 = New-AzCosmosDBCassandraClusterKey -Name "ColumnB" -OrderBy "Asc"
$schema = New-AzCosmosDBCassandraSchema -Column $Column1,$Column2 -ClusterKey $clusterkey1 -PartitionKey "ColumnA"

$NewTable = Set-AzCosmosDBCassandraTable -AccountName $AccountName -ResourceGroupName $rgName -KeyspaceName $KeyspaceName -Name $TableName -Schema $schema
Assert-AreEqual $NewTable.Name $TableName

$Keyspace = Get-AzCosmosDBCassandraKeyspace -AccountName $AccountName -ResourceGroupName $rgName -Name $KeyspaceName
Assert-AreEqual $NewKeyspace.Id $Keyspace.Id
Assert-AreEqual $NewKeyspace.Name $Keyspace.Name
Assert-AreEqual $NewKeyspace.Resource.Id $Keyspace.Resource.Id
Assert-AreEqual $NewKeyspace.Resource._rid $Keyspace.Resource._rid
Assert-AreEqual $NewKeyspace.Resource._ts $Keyspace.Resource._ts
Assert-AreEqual $NewKeyspace.Resource._etag $Keyspace.Resource._etag

$Table = Get-AzCosmosDBCassandraTable -AccountName $AccountName -ResourceGroupName $rgName -KeyspaceName $KeyspaceName -Name $TableName
Assert-AreEqual $NewTable.Id $Table.Id
Assert-AreEqual $NewTable.Name $Table.Name
Assert-AreEqual $NewTable.Resource.Id $Table.Resource.Id
Assert-AreEqual $NewTable.Resource._rid $Table.Resource._rid
Assert-AreEqual $NewTable.Resource._ts $Table.Resource._ts
Assert-AreEqual $NewTable.Resource._etag $Table.Resource._etag

$ListTables = Get-AzCosmosDBCassandraTable -AccountName $AccountName -ResourceGroupName $rgName -KeyspaceName $KeyspaceName
Assert-NotNull($ListTables)

$ListKeyspaces = Get-AzCosmosDBCassandraKeyspace -AccountName $AccountName -ResourceGroupName $rgName
Assert-NotNull($ListKeyspaces)

$IsTableRemoved = Remove-AzCosmosDBCassandraTable -AccountName $AccountName -ResourceGroupName $rgName -KeyspaceName $KeyspaceName -Name $TableName -PassThru
Assert-AreEqual $IsTableRemoved true

$IsKeyspaceRemoved = Remove-AzCosmosDBCassandraKeyspace -AccountName $AccountName -ResourceGroupName $rgName -Name $KeyspaceName -PassThru
Assert-AreEqual $IsKeyspaceRemoved true
}

function Test-CassandraOperationsCmdletsUsingInputObject
{
$AccountName = "db2725"
$rgName = "CosmosDBResourceGroup2510"
$KeyspaceName = "db2"
$TableName = "table"

$cosmosDBAccount = Get-AzCosmosDBAccount -ResourceGroupName $rgName -Name $AccountName

$NewKeyspace = Set-AzCosmosDBCassandraKeyspace -InputObject $cosmosDBAccount -Name $KeyspaceName
Assert-AreEqual $NewKeyspace.Name $KeyspaceName

$Column1 = New-AzCosmosDBCassandraColumn -Name "ColumnA" -Type "int"
$Column2 = New-AzCosmosDBCassandraColumn -Name "ColumnB" -Type "ascii"
$clusterkey1 = New-AzCosmosDBCassandraClusterKey -Name "ColumnB" -OrderBy "Asc"
$schema = New-AzCosmosDBCassandraSchema -Column $Column1,$Column2 -ClusterKey $clusterkey1 -PartitionKey "ColumnA"

$NewTable = Set-AzCosmosDBCassandraTable -InputObject $NewKeyspace -Name $TableName -Schema $schema
Assert-AreEqual $NewTable.Name $TableName

$Keyspace = Get-AzCosmosDBCassandraKeyspace -InputObject $cosmosDBAccount -Name $KeyspaceName
Assert-AreEqual $NewKeyspace.Id $Keyspace.Id
Assert-AreEqual $NewKeyspace.Name $Keyspace.Name
Assert-AreEqual $NewKeyspace.Resource.Id $Keyspace.Resource.Id
Assert-AreEqual $NewKeyspace.Resource._rid $Keyspace.Resource._rid
Assert-AreEqual $NewKeyspace.Resource._ts $Keyspace.Resource._ts
Assert-AreEqual $NewKeyspace.Resource._etag $Keyspace.Resource._etag

$Table = Get-AzCosmosDBCassandraTable -InputObject $NewKeyspace -Name $TableName
Assert-AreEqual $NewTable.Id $Table.Id
Assert-AreEqual $NewTable.Name $Table.Name
Assert-AreEqual $NewTable.Resource.Id $Table.Resource.Id
Assert-AreEqual $NewTable.Resource._rid $Table.Resource._rid
Assert-AreEqual $NewTable.Resource._ts $Table.Resource._ts
Assert-AreEqual $NewTable.Resource._etag $Table.Resource._etag

$ListTables = Get-AzCosmosDBCassandraTable -InputObject $NewKeyspace
Assert-NotNull($ListTables)

$ListKeyspaces = Get-AzCosmosDBCassandraKeyspace -InputObject $cosmosDBAccount
Assert-NotNull($ListKeyspaces)

$IsTableRemoved = Remove-AzCosmosDBCassandraTable -InputObject $NewTable -PassThru
Assert-AreEqual $IsTableRemoved true

$IsKeyspaceRemoved = Remove-AzCosmosDBCassandraKeyspace -InputObject $NewKeyspace -PassThru
Assert-AreEqual $IsKeyspaceRemoved true
}
44 changes: 44 additions & 0 deletions src/CosmosDB/CosmosDB.Test/ScenarioTests/GremlinOperationsTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// ----------------------------------------------------------------------------------
//
// Copyright Microsoft Corporation
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// ----------------------------------------------------------------------------------

using Microsoft.WindowsAzure.Commands.ScenarioTest;
using Xunit;

namespace Microsoft.Azure.Commands.CosmosDB.Test.ScenarioTests.ScenarioTest
{
public class GremlinOperationsTests
{
private ServiceManagement.Common.Models.XunitTracingInterceptor _logger;

public GremlinOperationsTests(Xunit.Abstractions.ITestOutputHelper output)
{
_logger = new ServiceManagement.Common.Models.XunitTracingInterceptor(output);
ServiceManagement.Common.Models.XunitTracingInterceptor.AddToContext(_logger);
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestGremlinOperationsCmdlets()
{
TestController.NewInstance.RunPowerShellTest(_logger, "Test-GremlinOperationsCmdlets");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestGremlinOperationsCmdletsUsingInputObject()
{
TestController.NewInstance.RunPowerShellTest(_logger, "Test-GremlinOperationsCmdletsUsingInputObject");
}
}
}
134 changes: 134 additions & 0 deletions src/CosmosDB/CosmosDB.Test/ScenarioTests/GremlinOperationsTests.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
# ----------------------------------------------------------------------------------
#
# Copyright Microsoft Corporation
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ----------------------------------------------------------------------------------
<#
.SYNOPSIS
Gets and removes custom domain with running endpoint.
#>

function Test-GremlinOperationsCmdlets
{
$AccountName = "db1002"
$rgName = "CosmosDBResourceGroup2510"
$DatabaseName = "dbName"
$GraphName = "graph1"

$PartitionKeyPathValue = "/foo"
$PartitionKeyKindValue = "Hash"

$NewDatabase = Set-AzCosmosDBGremlinDatabase -AccountName $AccountName -ResourceGroupName $rgName -Name $DatabaseName
Assert-AreEqual $NewDatabase.Name $DatabaseName

#Indexing Policy Creation
$ipath1 = New-AzCosmosDBGremlinIncludedPathIndex -DataType String -Precision -1 -Kind Hash
$ipath2 = New-AzCosmosDBGremlinIncludedPathIndex -DataType String -Precision -1 -Kind Hash
$IncludedPath = New-AzCosmosDBGremlinIncludedPath -Path "/*" -Index $ipath1, $ipath2
$SpatialSpec = New-AzCosmosDBGremlinSpatialSpec -Path "/mySpatialPath/*" -Type "Point", "LineString", "Polygon", "MultiPolygon"
$cp1 = New-AzCosmosDBGremlinCompositePath -Path "/abc" -Order Ascending
$cp2 = New-AzCosmosDBGremlinCompositePath -Path "/aberc" -Order Descending
$CompositePaths = (($cp1, $cp2), ($cp2, $cp1))

$IndexingPolicy = New-AzCosmosDBGremlinIndexingPolicy -IncludedPath $IncludedPath -SpatialSpec $SpatialSpec -CompositePath $CompositePaths -ExcludedPath "/myPathToNotIndex/*" -Automatic 1 -IndexingMode Consistent

#UniqueKey Creation
$p1 = New-AzCosmosDBGremlinUniqueKey -Path "/myUniqueKey3"
$p2 = New-AzCosmosDBGremlinUniqueKey -Path "/myUniqueKey4"
$p3 = New-AzCosmosDBGremlinUniqueKey -Path "/myUniqueKey2"
$p4 = New-AzCosmosDBGremlinUniqueKey -Path "/myUniqueKey1"

$uk1 = New-AzCosmosDBGremlinUniqueKeyPolicy -UniqueKey $p1,$p2,$p3,$p4

$NewGraph = Set-AzCosmosDBGremlinGraph -AccountName $AccountName -ResourceGroupName $rgName -DatabaseName $DatabaseName -Name $GraphName -PartitionKeyPath $PartitionKeyPathValue -PartitionKeyKind $PartitionKeyKindValue -IndexingPolicy $IndexingPolicy -UniqueKeyPolicy $uk1
Assert-AreEqual $NewGraph.Name $GraphName
Assert-AreEqual $NewGraph.Resource.IndexingPolicy.Automatic $IndexingPolicy.Automatic
Assert-AreEqual $NewGraph.Resource.IndexingPolicy.IndexingMode $IndexingPolicy.IndexingMode
Assert-AreEqual $NewGraph.Resource.IndexingPolicy.IncludedPath.Path $IndexingPolicy.IncludedPath.Path
Assert-AreEqual $NewGraph.Resource.IndexingPolicy.CompositeIndexes.Count 2
Assert-AreEqual $NewGraph.Resource.IndexingPolicy.SpatialIndexes.Path $SpatialSpec.Path
Assert-AreEqual $NewGraph.Resource.UniqueKeyPolicy.UniqueKeys.Count 4

$Database = Get-AzCosmosDBGremlinDatabase -AccountName $AccountName -ResourceGroupName $rgName -Name $DatabaseName
Assert-AreEqual $NewDatabase.Id $Database.Id
Assert-AreEqual $NewDatabase.Name $Database.Name
Assert-AreEqual $NewDatabase.Resource.Id $Database.Resource.Id
Assert-AreEqual $NewDatabase.Resource._rid $Database.Resource._rid
Assert-AreEqual $NewDatabase.Resource._ts $Database.Resource._ts
Assert-AreEqual $NewDatabase.Resource._etag $Database.Resource._etag

$Graph = Get-AzCosmosDBGremlinGraph -AccountName $AccountName -ResourceGroupName $rgName -DatabaseName $DatabaseName -Name $GraphName
Assert-AreEqual $NewGraph.Id $Graph.Id
Assert-AreEqual $NewGraph.Name $Graph.Name
Assert-AreEqual $NewGraph.GremlinGraphGetResultsId $Graph.GremlinGraphGetResultsId
Assert-AreEqual $NewGraph._rid $Graph._rid
Assert-AreEqual $NewGraph._ts $Graph._ts
Assert-AreEqual $NewGraph._etag $Graph._etag

$ListGraphs = Get-AzCosmosDBGremlinGraph -AccountName $AccountName -ResourceGroupName $rgName -DatabaseName $DatabaseName
Assert-NotNull($ListGraphs)

$ListDatabases = Get-AzCosmosDBGremlinDatabase -AccountName $AccountName -ResourceGroupName $rgName
Assert-NotNull($ListDatabases)

$IsGraphRemoved = Remove-AzCosmosDBGremlinGraph -AccountName $AccountName -ResourceGroupName $rgName -DatabaseName $DatabaseName -Name $GraphName -PassThru
Assert-AreEqual $IsGraphRemoved true

$IsDatabaseRemoved = Remove-AzCosmosDBGremlinDatabase -AccountName $AccountName -ResourceGroupName $rgName -Name $DatabaseName -PassThru
Assert-AreEqual $IsDatabaseRemoved true
}

function Test-GremlinOperationsCmdletsUsingInputObject
{
$AccountName = "db1002"
$rgName = "CosmosDBResourceGroup2510"
$DatabaseName = "dbName2"
$GraphName = "graph1"

$PartitionKeyPathValue = "/foo"
$PartitionKeyKindValue = "Hash"

$cosmosDBAccount = Get-AzCosmosDBAccount -ResourceGroupName $rgName -Name $AccountName

$NewDatabase = Set-AzCosmosDBGremlinDatabase -InputObject $cosmosDBAccount -Name $DatabaseName
Assert-AreEqual $NewDatabase.Name $DatabaseName

$NewGraph = Set-AzCosmosDBGremlinGraph -InputObject $NewDatabase -Name $GraphName -PartitionKeyPath $PartitionKeyPathValue -PartitionKeyKind $PartitionKeyKindValue
Assert-AreEqual $NewGraph.Name $GraphName

$Database = Get-AzCosmosDBGremlinDatabase -InputObject $cosmosDBAccount -Name $DatabaseName
Assert-AreEqual $NewDatabase.Id $Database.Id
Assert-AreEqual $NewDatabase.Name $Database.Name
Assert-AreEqual $NewDatabase.Resource.Id $Database.Resource.Id
Assert-AreEqual $NewDatabase.Resource._rid $Database.Resource._rid
Assert-AreEqual $NewDatabase.Resource._ts $Database.Resource._ts
Assert-AreEqual $NewDatabase.Resource._etag $Database.Resource._etag

$Graph = Get-AzCosmosDBGremlinGraph -InputObject $NewDatabase -Name $GraphName
Assert-AreEqual $NewGraph.Id $Graph.Id
Assert-AreEqual $NewGraph.Name $Graph.Name
Assert-AreEqual $NewGraph.Resource.Id $Graph.Resource.Id
Assert-AreEqual $NewGraph.Resource._rid $Graph.Resource._rid
Assert-AreEqual $NewGraph.Resource._ts $Graph.Resource._ts
Assert-AreEqual $NewGraph.Resource._etag $Graph.Resource._etag

$ListGraphs = Get-AzCosmosDBGremlinGraph -InputObject $NewDatabase
Assert-NotNull($ListGraphs)

$ListDatabases = Get-AzCosmosDBGremlinDatabase -InputObject $cosmosDBAccount
Assert-NotNull($ListDatabases)

$IsGraphRemoved = Remove-AzCosmosDBGremlinGraph -InputObject $NewGraph -PassThru
Assert-AreEqual $IsGraphRemoved true

$IsDatabaseRemoved = Remove-AzCosmosDBGremlinDatabase -InputObject $NewDatabase -PassThru
Assert-AreEqual $IsDatabaseRemoved true
}
Loading