Skip to content

Commit

Permalink
Merge pull request #18 from GaryHopeMS/master
Browse files Browse the repository at this point in the history
Include deployment
  • Loading branch information
GaryHopeMS authored Sep 20, 2021
2 parents a275cde + 30f57a3 commit cf04c04
Show file tree
Hide file tree
Showing 11 changed files with 537 additions and 4 deletions.
11 changes: 11 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
################################################################################
# This .gitignore file was automatically created by Microsoft(R) Visual Studio.
################################################################################

/change-feed-categories/bin
/modeling-demos/bin
/models/bin
/change-feed-categories/obj
/modeling-demos/obj
/models/obj
/modeling-demos/appSettings.json
Binary file modified .vs/CosmicWorks/v16/.suo
Binary file not shown.
Binary file modified .vs/slnx.sqlite
Binary file not shown.
Binary file not shown.
382 changes: 382 additions & 0 deletions modeling-demos/Deployment.cs

Large diffs are not rendered by default.

30 changes: 28 additions & 2 deletions modeling-demos/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class Program

private static readonly string uri = config["uri"];
private static readonly string key = config["key"];

private static readonly CosmosClient client = new CosmosClient(uri, key);

public static async Task Main(string[] args)
Expand All @@ -44,6 +45,11 @@ public static async Task Main(string[] args)
Console.WriteLine($"[h] Create new order and update order total");
Console.WriteLine($"[i] Delete order and update order total");
Console.WriteLine($"[j] Query top 10 customers");
Console.WriteLine($"-------------------------------------------");
Console.WriteLine($"[k] Create databases and containers");
Console.WriteLine($"[l] Upload data to containers");
Console.WriteLine($"[m] Delete databases and containers");
Console.WriteLine($"-------------------------------------------");
Console.WriteLine($"[x] Exit");

ConsoleKeyInfo result = Console.ReadKey(true);
Expand Down Expand Up @@ -101,6 +107,26 @@ public static async Task Main(string[] args)
Console.Clear();
await GetTop10Customers();
}
else if (result.KeyChar == 'k')
{
// Create databases and containers
await Deployment.CreateDatabase(client);
Console.Clear();

}
else if (result.KeyChar == 'l')
{
//Upload data to containers
await Deployment.LoadDatabase(client);
Console.Clear();
}
else if (result.KeyChar == 'm')
{
//Delete databases and containers
await Deployment.DeleteDatabase(client);
Console.Clear();

}
else if (result.KeyChar == 'x')
{
exit = true;
Expand Down Expand Up @@ -515,7 +541,7 @@ public static void Print(object obj)

class Secrets
{
public string uri;
public string key;
public string uri="";
public string key="";
}
}
4 changes: 2 additions & 2 deletions modeling-demos/appSettings.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"uri": "",
"key": ""
"uri": "https://contoso-retail.documents.azure.com:443/",
"key": "07RGov3dtzCTU9Zwe1y9NtN9g9sYpIXR7jlFPMNbLNb21QLzMF0rLu302Y54PyaNVmkSxCorL46W5bMvqeuGyA=="
}
111 changes: 111 additions & 0 deletions modeling-demos/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
{
"resources": {
"databases": [
{
"name": "database-v1",
"maxThroughput": 4000,
"containers": [
{
"name": "customer",
"pk": "/id"
},
{
"name": "customerAddress",
"pk": "/id"
},
{
"name": "customerPassword",
"pk": "/id"
},
{
"name": "product",
"pk": "/id"
},
{
"name": "productCategory",
"pk": "/id"
},
{
"name": "productTag",
"pk": "/id"
},
{
"name": "productTags",
"pk": "/id"
},
{
"name": "salesOrder",
"pk": "/id"
},
{
"name": "salesOrderDetail",
"pk": "/id"
}
]
},
{
"name": "database-v2",
"maxThroughput": 4000,
"containers": [
{
"name": "customer",
"pk": "/id"
},
{
"name": "product",
"pk": "/categoryId"
},
{
"name": "productCategory",
"pk": "/type"
},
{
"name": "productTag",
"pk": "/type"
},
{
"name": "salesOrder",
"pk": "/customerId"
}
]
},
{
"name": "database-v3",
"maxThroughput": 4000,
"containers": [
{
"name": "customer",
"pk": "/customerId"
},
{
"name": "product",
"pk": "/categoryId"
},
{
"name": "productMeta",
"pk": "/type"
}
]
},
{
"name": "database-v4",
"maxThroughput": 4000,
"containers": [
{
"name": "customer",
"pk": "/customerId"
},
{
"name": "product",
"pk": "/categoryId"
},
{
"name": "productMeta",
"pk": "/type"
}
]
}
]

}
}
3 changes: 3 additions & 0 deletions modeling-demos/modeling-demos.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@
<None Update="appSettings.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="config.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>

</Project>
Binary file not shown.
Binary file modified models/obj/Debug/netcoreapp3.1/models.csproj.AssemblyReference.cache
Binary file not shown.

0 comments on commit cf04c04

Please sign in to comment.