Skip to content

Commit 68adc7c

Browse files
Refactor solution and add new Bicep deployment files
- Removed `Sample.Datasync.Server.SingleContainer` project from `Datasync.Toolkit.sln`. - Added `CommunityToolkit.Datasync.Server.CosmosDb.Test` to the solution. - Created new solution file `Datasync.Server.CosmosDb.SingleContainer.sln` with relevant projects. - Updated `main.bicep` to include licensing and resource deployment parameters. - Added `main.parameters.json` for Bicep deployment parameters. - Created `resources.bicep` to define CosmosDB and App Service resources. - Updated `Sample.Datasync.Server.SingleContainer.csproj` with necessary project references.
1 parent 5707901 commit 68adc7c

File tree

16 files changed

+263
-28
lines changed

16 files changed

+263
-28
lines changed

Datasync.Toolkit.sln

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sample.Datasync.Server", "s
6666
EndProject
6767
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CommunityToolkit.Datasync.Server.CosmosDb", "src\CommunityToolkit.Datasync.Server.CosmosDb\CommunityToolkit.Datasync.Server.CosmosDb.csproj", "{D9356867-0A30-4B17-BD4C-0F7EF70984C6}"
6868
EndProject
69-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sample.Datasync.Server.SingleContainer", "samples\datasync-server\datasync-server-cosmosdb\Sample.Datasync.Server.SingleContainer\Sample.Datasync.Server.SingleContainer.csproj", "{60C73E92-9A45-4EE6-8DCF-48206CD0E5FE}"
70-
EndProject
7169
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CommunityToolkit.Datasync.Server.MongoDB", "src\CommunityToolkit.Datasync.Server.MongoDB\CommunityToolkit.Datasync.Server.MongoDB.csproj", "{DC20ACF9-12E9-41D9-B672-CB5FD85548E9}"
7270
EndProject
7371
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CommunityToolkit.Datasync.Server.MongoDB.Test", "tests\CommunityToolkit.Datasync.Server.MongoDB.Test\CommunityToolkit.Datasync.Server.MongoDB.Test.csproj", "{4FC45D20-0BA9-484B-9040-641687659AF6}"
@@ -172,14 +170,6 @@ Global
172170
{D9356867-0A30-4B17-BD4C-0F7EF70984C6}.Debug|Any CPU.Build.0 = Debug|Any CPU
173171
{D9356867-0A30-4B17-BD4C-0F7EF70984C6}.Release|Any CPU.ActiveCfg = Release|Any CPU
174172
{D9356867-0A30-4B17-BD4C-0F7EF70984C6}.Release|Any CPU.Build.0 = Release|Any CPU
175-
{60C73E92-9A45-4EE6-8DCF-48206CD0E5FE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
176-
{60C73E92-9A45-4EE6-8DCF-48206CD0E5FE}.Debug|Any CPU.Build.0 = Debug|Any CPU
177-
{60C73E92-9A45-4EE6-8DCF-48206CD0E5FE}.Release|Any CPU.ActiveCfg = Release|Any CPU
178-
{60C73E92-9A45-4EE6-8DCF-48206CD0E5FE}.Release|Any CPU.Build.0 = Release|Any CPU
179-
{FC15CF34-2C1A-4B15-85CC-A99EA25C47D2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
180-
{FC15CF34-2C1A-4B15-85CC-A99EA25C47D2}.Debug|Any CPU.Build.0 = Debug|Any CPU
181-
{FC15CF34-2C1A-4B15-85CC-A99EA25C47D2}.Release|Any CPU.ActiveCfg = Release|Any CPU
182-
{FC15CF34-2C1A-4B15-85CC-A99EA25C47D2}.Release|Any CPU.Build.0 = Release|Any CPU
183173
{DC20ACF9-12E9-41D9-B672-CB5FD85548E9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
184174
{DC20ACF9-12E9-41D9-B672-CB5FD85548E9}.Debug|Any CPU.Build.0 = Debug|Any CPU
185175
{DC20ACF9-12E9-41D9-B672-CB5FD85548E9}.Release|Any CPU.ActiveCfg = Release|Any CPU
@@ -196,6 +186,10 @@ Global
196186
{505421EC-2598-4114-B2EC-997959B89E74}.Debug|Any CPU.Build.0 = Debug|Any CPU
197187
{505421EC-2598-4114-B2EC-997959B89E74}.Release|Any CPU.ActiveCfg = Release|Any CPU
198188
{505421EC-2598-4114-B2EC-997959B89E74}.Release|Any CPU.Build.0 = Release|Any CPU
189+
{FC15CF34-2C1A-4B15-85CC-A99EA25C47D2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
190+
{FC15CF34-2C1A-4B15-85CC-A99EA25C47D2}.Debug|Any CPU.Build.0 = Debug|Any CPU
191+
{FC15CF34-2C1A-4B15-85CC-A99EA25C47D2}.Release|Any CPU.ActiveCfg = Release|Any CPU
192+
{FC15CF34-2C1A-4B15-85CC-A99EA25C47D2}.Release|Any CPU.Build.0 = Release|Any CPU
199193
EndGlobalSection
200194
GlobalSection(SolutionProperties) = preSolution
201195
HideSolutionNode = FALSE
@@ -223,10 +217,9 @@ Global
223217
{2889E6B2-9CD1-437C-A43C-98CFAFF68B99} = {D59F1489-5D74-4F52-B78B-88037EAB2838}
224218
{A9967817-2A2C-4C6D-A133-967A6062E9B3} = {75F709FD-8CC2-4558-A802-FE57086167C2}
225219
{D9356867-0A30-4B17-BD4C-0F7EF70984C6} = {84AD662A-4B9E-4E64-834D-72529FB7FCE5}
226-
{60C73E92-9A45-4EE6-8DCF-48206CD0E5FE} = {75F709FD-8CC2-4558-A802-FE57086167C2}
227-
{FC15CF34-2C1A-4B15-85CC-A99EA25C47D2} = {D59F1489-5D74-4F52-B78B-88037EAB2838}
228220
{DC20ACF9-12E9-41D9-B672-CB5FD85548E9} = {84AD662A-4B9E-4E64-834D-72529FB7FCE5}
229221
{4FC45D20-0BA9-484B-9040-641687659AF6} = {D59F1489-5D74-4F52-B78B-88037EAB2838}
222+
{FC15CF34-2C1A-4B15-85CC-A99EA25C47D2} = {D59F1489-5D74-4F52-B78B-88037EAB2838}
230223
{99E727A3-8EB3-437E-AAC8-3596E8B9B2AE} = {D59F1489-5D74-4F52-B78B-88037EAB2838}
231224
{505421EC-2598-4114-B2EC-997959B89E74} = {84AD662A-4B9E-4E64-834D-72529FB7FCE5}
232225
EndGlobalSection
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.12.35728.132
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sample.Datasync.Server.SingleContainer", "src\Sample.Datasync.Server.SingleContainer.csproj", "{5C9AB15D-EBE4-4F60-939C-B24E73F4174E}"
7+
EndProject
8+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Projects", "Projects", "{2410E728-3A10-4E61-BCE0-64031E9ABC1C}"
9+
EndProject
10+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CommunityToolkit.Datasync.Server.CosmosDb", "..\..\src\CommunityToolkit.Datasync.Server.CosmosDb\CommunityToolkit.Datasync.Server.CosmosDb.csproj", "{2CA5DC15-69DE-47EA-9FF3-595E6D6D9FB5}"
11+
EndProject
12+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CommunityToolkit.Datasync.Server.Swashbuckle", "..\..\src\CommunityToolkit.Datasync.Server.Swashbuckle\CommunityToolkit.Datasync.Server.Swashbuckle.csproj", "{98195FB2-DABA-48F6-8D52-50CF920B4F72}"
13+
EndProject
14+
Global
15+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
16+
Debug|Any CPU = Debug|Any CPU
17+
Release|Any CPU = Release|Any CPU
18+
EndGlobalSection
19+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
20+
{5C9AB15D-EBE4-4F60-939C-B24E73F4174E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
21+
{5C9AB15D-EBE4-4F60-939C-B24E73F4174E}.Debug|Any CPU.Build.0 = Debug|Any CPU
22+
{5C9AB15D-EBE4-4F60-939C-B24E73F4174E}.Release|Any CPU.ActiveCfg = Release|Any CPU
23+
{5C9AB15D-EBE4-4F60-939C-B24E73F4174E}.Release|Any CPU.Build.0 = Release|Any CPU
24+
{2CA5DC15-69DE-47EA-9FF3-595E6D6D9FB5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
25+
{2CA5DC15-69DE-47EA-9FF3-595E6D6D9FB5}.Debug|Any CPU.Build.0 = Debug|Any CPU
26+
{2CA5DC15-69DE-47EA-9FF3-595E6D6D9FB5}.Release|Any CPU.ActiveCfg = Release|Any CPU
27+
{2CA5DC15-69DE-47EA-9FF3-595E6D6D9FB5}.Release|Any CPU.Build.0 = Release|Any CPU
28+
{98195FB2-DABA-48F6-8D52-50CF920B4F72}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
29+
{98195FB2-DABA-48F6-8D52-50CF920B4F72}.Debug|Any CPU.Build.0 = Debug|Any CPU
30+
{98195FB2-DABA-48F6-8D52-50CF920B4F72}.Release|Any CPU.ActiveCfg = Release|Any CPU
31+
{98195FB2-DABA-48F6-8D52-50CF920B4F72}.Release|Any CPU.Build.0 = Release|Any CPU
32+
EndGlobalSection
33+
GlobalSection(SolutionProperties) = preSolution
34+
HideSolutionNode = FALSE
35+
EndGlobalSection
36+
GlobalSection(NestedProjects) = preSolution
37+
{2CA5DC15-69DE-47EA-9FF3-595E6D6D9FB5} = {2410E728-3A10-4E61-BCE0-64031E9ABC1C}
38+
{98195FB2-DABA-48F6-8D52-50CF920B4F72} = {2410E728-3A10-4E61-BCE0-64031E9ABC1C}
39+
EndGlobalSection
40+
EndGlobal
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
// See the LICENSE file in the project root for more information.
4+
5+
targetScope = 'subscription'
6+
7+
@minLength(1)
8+
@maxLength(64)
9+
@description('Name of the the environment which is used to generate a short unique hash used in all resources.')
10+
param environmentName string
11+
12+
@minLength(1)
13+
@description('Primary location for all resources')
14+
param location string
15+
16+
@description('Optional - the name of the App Service to create. If not provided, a unique name will be generated.')
17+
param appServiceName string = ''
18+
19+
@description('Optional - the name of the App Service Plan to create. If not provided, a unique name will be generated.')
20+
param appServicePlanName string = ''
21+
22+
@description('Optional - the name of the Resource Group to create. If not provided, a unique name will be generated.')
23+
param resourceGroupName string = ''
24+
25+
var resourceToken = toLower(uniqueString(subscription().id, environmentName, location))
26+
var tags = { 'azd-env-name': environmentName }
27+
28+
resource resourceGroup 'Microsoft.Resources/resourceGroups@2022-09-01' = {
29+
name: !empty(resourceGroupName) ? resourceGroupName : 'rg-${environmentName}'
30+
location: location
31+
tags: tags
32+
}
33+
34+
module resources './resources.bicep' = {
35+
name: 'resources'
36+
scope: resourceGroup
37+
params: {
38+
location: location
39+
tags: tags
40+
appServiceName: !empty(appServiceName) ? appServiceName : 'app-${resourceToken}'
41+
appServicePlanName: !empty(appServicePlanName) ? appServicePlanName : 'asp-${resourceToken}'
42+
accountName: 'cosmosdb-${resourceToken}'
43+
databaseName: 'TodoDb'
44+
containerName: 'TodoContainer'
45+
}
46+
}
47+
48+
output SERVICE_ENDPOINT string = resources.outputs.SERVICE_ENDPOINT
49+
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#",
3+
"contentVersion": "1.0.0.0",
4+
"parameters": {
5+
"environmentName": {
6+
"value": "${AZURE_ENV_NAME}"
7+
},
8+
"location": {
9+
"value": "${AZURE_LOCATION}"
10+
}
11+
}
12+
}
Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
targetScope = 'resourceGroup'
2+
3+
@minLength(1)
4+
@description('Primary location for all resources')
5+
param location string
6+
7+
@description('The name of the App Service to create.')
8+
param appServiceName string
9+
10+
@description('The name of the App Service Plan to create.')
11+
param appServicePlanName string
12+
13+
@description('The list of tags to apply to all resources.')
14+
param tags object = {}
15+
16+
@description('The name for the CosmosDB account')
17+
param accountName string
18+
19+
@description('The name for the database')
20+
param databaseName string
21+
22+
@description('The name for the container')
23+
param containerName string
24+
25+
resource account 'Microsoft.DocumentDB/databaseAccounts@2022-05-15' = {
26+
name: toLower(accountName)
27+
kind: 'GlobalDocumentDB'
28+
location: location
29+
properties: {
30+
consistencyPolicy: {
31+
defaultConsistencyLevel: 'Session'}
32+
locations: [
33+
{
34+
locationName: location
35+
}
36+
]
37+
databaseAccountOfferType: 'Standard'
38+
}
39+
}
40+
41+
resource database 'Microsoft.DocumentDB/databaseAccounts/sqlDatabases@2022-05-15' = {
42+
parent: account
43+
name: databaseName
44+
properties: {
45+
resource: {
46+
id: databaseName
47+
}
48+
options: {
49+
throughput: 1000
50+
}
51+
}
52+
}
53+
54+
resource container 'Microsoft.DocumentDB/databaseAccounts/sqlDatabases/containers@2022-05-15' = {
55+
parent: database
56+
name: containerName
57+
properties: {
58+
resource: {
59+
id: containerName
60+
partitionKey: {
61+
paths: [
62+
'/myPartitionKey'
63+
]
64+
kind: 'Hash'
65+
}
66+
indexingPolicy: {
67+
indexingMode: 'consistent'
68+
includedPaths: [
69+
{
70+
path: '/*'
71+
}
72+
]
73+
excludedPaths: [
74+
{
75+
path: '/_etag/?'
76+
}
77+
]
78+
compositeIndexes: [
79+
[
80+
{
81+
path: '/name'
82+
order: 'ascending'
83+
}
84+
{
85+
path: '/age'
86+
order: 'descending'
87+
}
88+
]
89+
]
90+
}
91+
}
92+
}
93+
}
94+
95+
resource appServicePlan 'Microsoft.Web/serverfarms@2022-09-01' = {
96+
name: appServicePlanName
97+
location: location
98+
tags: tags
99+
sku: {
100+
name: 'B1'
101+
capacity: 1
102+
}
103+
}
104+
105+
resource appService 'Microsoft.Web/sites@2022-09-01' = {
106+
name: appServiceName
107+
location: location
108+
tags: union(tags, {
109+
'azd-service-name': 'backend'
110+
'hidden-related:${appServicePlan.id}': 'empty'
111+
})
112+
properties: {
113+
httpsOnly: true
114+
serverFarmId: appServicePlan.id
115+
siteConfig: {
116+
ftpsState: 'Disabled'
117+
minTlsVersion: '1.2'
118+
}
119+
}
120+
121+
resource configLogs 'config' = {
122+
name: 'logs'
123+
properties: {
124+
applicationLogs: { fileSystem: { level: 'Verbose' } }
125+
detailedErrorMessages: { enabled: true }
126+
failedRequestsTracing: { enabled: true }
127+
httpLogs: { fileSystem: { retentionInMb: 35, retentionInDays: 3, enabled: true } }
128+
}
129+
}
130+
131+
resource connectionStrings 'config' = {
132+
name: 'connectionstrings'
133+
properties: {
134+
DefaultConnection: {
135+
value: account.listConnectionStrings().connectionStrings[0].connectionString
136+
type: 'DocDb'
137+
}
138+
}
139+
}
140+
}
141+
142+
output SERVICE_ENDPOINT string = 'https://${appService.properties.defaultHostName}'

samples/datasync-server/datasync-server-cosmosdb/Sample.Datasync.Server.SingleContainer/Controllers/TodoItemController.cs renamed to samples/datasync-server-cosmosdb-singlecontainer/src/Controllers/TodoItemController.cs

File renamed without changes.

samples/datasync-server/datasync-server-cosmosdb/Sample.Datasync.Server.SingleContainer/Controllers/TodoListController.cs renamed to samples/datasync-server-cosmosdb-singlecontainer/src/Controllers/TodoListController.cs

File renamed without changes.

samples/datasync-server/datasync-server-cosmosdb/Sample.Datasync.Server.SingleContainer/Models/TodoItem.cs renamed to samples/datasync-server-cosmosdb-singlecontainer/src/Models/TodoItem.cs

File renamed without changes.

samples/datasync-server/datasync-server-cosmosdb/Sample.Datasync.Server.SingleContainer/Models/TodoList.cs renamed to samples/datasync-server-cosmosdb-singlecontainer/src/Models/TodoList.cs

File renamed without changes.

samples/datasync-server/datasync-server-cosmosdb/Sample.Datasync.Server.SingleContainer/Program.cs renamed to samples/datasync-server-cosmosdb-singlecontainer/src/Program.cs

File renamed without changes.

0 commit comments

Comments
 (0)