Skip to content

Instantly share code, notes, and snippets.

@eosfor
Last active December 12, 2017 15:30
Show Gist options
  • Save eosfor/b952bac8c7c54c31f56b7bf30853b00a to your computer and use it in GitHub Desktop.
Save eosfor/b952bac8c7c54c31f56b7bf30853b00a to your computer and use it in GitHub Desktop.
Adding a VM to DocumentDB
using assembly "C:\Users\<username>\AppData\Local\PackageManagement\NuGet\Packages\Microsoft.Azure.DocumentDB.1.19.1\lib\net45\Microsoft.Azure.Documents.Client.dll"
$client = [Microsoft.Azure.Documents.Client.DocumentClient]::new([Uri]("https://localhost:8081"),"C2y6yDjf5/R+ob0N8A7Cgv30VRDJIWEHLM+4QDU5DE2nQ9nDuVTqobD4b8mGGyPMbIZnqyMsEcaGQy67XIw/Jw==")
$db = $client.CreateDatabaseIfNotExistsAsync([Microsoft.Azure.Documents.Database]@{ID="azureinventory"})
$docCollection = $client.CreateDocumentCollectionIfNotExistsAsync([Microsoft.Azure.Documents.Client.UriFactory]::CreateDatabaseUri("azureinventory"),
[Microsoft.Azure.Documents.DocumentCollection]@{id="inventory"},
[Microsoft.Azure.Documents.Client.RequestOptions]@{OfferThroughput = 1000})
$docCollectionURI = [Microsoft.Azure.Documents.Client.UriFactory]::CreateCollectionUri("azureinventory", "inventory")
$queryOptions = [Microsoft.Azure.Documents.Client.RequestOptions]@{OfferThroughput = 1000}
Get-AzureRmVM | % {
$client.CreateDocumentAsync($docCollectionURI, $_, $options, $true)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment