@@ -746,4 +746,48 @@ function Test-ProvisionCosmosDBAccountBackupPolicyWithContinuous7DaysCmdLets {
746
746
Assert-NotNull $sourceRestorableAccount.DatabaseAccountName
747
747
Assert-NotNull $sourceRestorableAccount.CreationTime
748
748
Assert-NotNull $sourceRestorableAccount.OldestRestorableTime
749
+ }
750
+
751
+ function Test-SqlRestoreAccountPublicNetworkAccessCmdlets {
752
+ # use an existing account with the following information
753
+ $rgName = " CosmosDBResourceGroup64"
754
+ $cosmosDBAccountName = " restored2-cosmosdb-12103-3"
755
+ $sourceCosmosDBAccountName = " cosmosdb-12103"
756
+ $databaseName = " TestDB1" ;
757
+ $collectionName1 = " TestCollectionInDB1" ;
758
+ $collectionName2 = " TestCollectionInDB2" ;
759
+ $location = " West US"
760
+ $apiKind = " Sql"
761
+ $consistencyLevel = " Session"
762
+ $PartitionKeyPathValue = " /foo/bar"
763
+ $PartitionKeyKindValue = " Hash"
764
+ $locations = @ ()
765
+ $locations += New-AzCosmosDBLocationObject - Location " West Us" - FailoverPriority 0 - IsZoneRedundant 0
766
+ $publicNetworkAccess = " Disabled"
767
+
768
+ $resourceGroup = New-AzResourceGroup - ResourceGroupName $rgName - Location $location
769
+ New-AzCosmosDBAccount - ResourceGroupName $rgName - LocationObject $locations - Name $sourceCosmosDBAccountName - ApiKind $apiKind - DefaultConsistencyLevel $consistencyLevel - BackupPolicyType Continuous
770
+ $NewDatabase = New-AzCosmosDBSqlDatabase - AccountName $sourceCosmosDBAccountName - ResourceGroupName $rgName - Name $databaseName
771
+ $NewContainer = New-AzCosmosDBSqlContainer - AccountName $sourceCosmosDBAccountName - ResourceGroupName $rgName - DatabaseName $databaseName - Name $collectionName1 - PartitionKeyPath $PartitionKeyPathValue - PartitionKeyKind $PartitionKeyKindValue - Throughput 600
772
+ $NewContainer = New-AzCosmosDBSqlContainer - AccountName $sourceCosmosDBAccountName - ResourceGroupName $rgName - DatabaseName $databaseName - Name $collectionName2 - PartitionKeyPath $PartitionKeyPathValue - PartitionKeyKind $PartitionKeyKindValue - Throughput 600
773
+ Start-TestSleep - Seconds 100
774
+
775
+ $datatabaseToRestore = New-AzCosmosDBDatabaseToRestore - DatabaseName $databaseName - CollectionName $collectionName1 , $collectionName2
776
+ $sourceCosmosDBAccount = Get-AzCosmosDBAccount - Name $sourceCosmosDBAccountName - ResourceGroupName $rgName
777
+ $sourceRestorableAccount = Get-AzCosmosDBRestorableDatabaseAccount - Location $sourceCosmosDBAccount.Location - DatabaseAccountInstanceId $sourceCosmosDBAccount.InstanceId
778
+ $restoreTimestampInUtc = $sourceRestorableAccount.CreationTime.AddSeconds (200 )
779
+ $restoredCosmosDBAccount = Restore-AzCosmosDBAccount - RestoreTimestampInUtc $restoreTimestampInUtc - SourceDatabaseAccountName $sourceCosmosDBAccountName - Location $sourceCosmosDBAccount.Location - TargetResourceGroupName $rgName - TargetDatabaseAccountName $cosmosDBAccountName - DatabasesToRestore $datatabaseToRestore - PublicNetworkAccess $publicNetworkAccess
780
+
781
+ Assert-NotNull $sourceRestorableAccount
782
+ Assert-AreEqual $restoredCosmosDBAccount.Name $cosmosDBAccountName
783
+ Assert-AreEqual $restoredCosmosDBAccount.CreateMode " Restore"
784
+ Assert-NotNull $restoredCosmosDBAccount.RestoreParameters
785
+ Assert-AreEqual $restoredCosmosDBAccount.RestoreParameters.RestoreSource $sourceRestorableAccount.Id
786
+
787
+ Assert-NotNull $restoredCosmosDBAccount.RestoreParameters.DatabasesToRestore
788
+ Assert-AreEqual $restoredCosmosDBAccount.RestoreParameters.DatabasesToRestore [0 ].DatabaseName $databaseName
789
+ Assert-AreEqual $restoredCosmosDBAccount.RestoreParameters.DatabasesToRestore [0 ].CollectionNames[0 ] $collectionName1
790
+
791
+ # Assert public network acccess is disabled
792
+ Assert-AreEqual $restoredCosmosDBAccount.PublicNetworkAccess $publicNetworkAccess
749
793
}
0 commit comments