Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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
14 changes: 14 additions & 0 deletions Datasync.Toolkit.sln
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "samples", "samples", "{75F7
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sample.Datasync.Server", "samples\datasync-server\src\Sample.Datasync.Server\Sample.Datasync.Server.csproj", "{A9967817-2A2C-4C6D-A133-967A6062E9B3}"
EndProject
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}"
EndProject
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}"
EndProject
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}"
Expand All @@ -72,6 +74,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CommunityToolkit.Datasync.S
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CommunityToolkit.Datasync.Server.OpenApi", "src\CommunityToolkit.Datasync.Server.OpenApi\CommunityToolkit.Datasync.Server.OpenApi.csproj", "{505421EC-2598-4114-B2EC-997959B89E74}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CommunityToolkit.Datasync.Server.CosmosDb.Test", "tests\CommunityToolkit.Datasync.Server.CosmosDb.Test\CommunityToolkit.Datasync.Server.CosmosDb.Test.csproj", "{FC15CF34-2C1A-4B15-85CC-A99EA25C47D2}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -162,6 +166,10 @@ Global
{A9967817-2A2C-4C6D-A133-967A6062E9B3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A9967817-2A2C-4C6D-A133-967A6062E9B3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A9967817-2A2C-4C6D-A133-967A6062E9B3}.Release|Any CPU.Build.0 = Release|Any CPU
{D9356867-0A30-4B17-BD4C-0F7EF70984C6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D9356867-0A30-4B17-BD4C-0F7EF70984C6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D9356867-0A30-4B17-BD4C-0F7EF70984C6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D9356867-0A30-4B17-BD4C-0F7EF70984C6}.Release|Any CPU.Build.0 = Release|Any CPU
{DC20ACF9-12E9-41D9-B672-CB5FD85548E9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{DC20ACF9-12E9-41D9-B672-CB5FD85548E9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{DC20ACF9-12E9-41D9-B672-CB5FD85548E9}.Release|Any CPU.ActiveCfg = Release|Any CPU
Expand All @@ -178,6 +186,10 @@ Global
{505421EC-2598-4114-B2EC-997959B89E74}.Debug|Any CPU.Build.0 = Debug|Any CPU
{505421EC-2598-4114-B2EC-997959B89E74}.Release|Any CPU.ActiveCfg = Release|Any CPU
{505421EC-2598-4114-B2EC-997959B89E74}.Release|Any CPU.Build.0 = Release|Any CPU
{FC15CF34-2C1A-4B15-85CC-A99EA25C47D2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{FC15CF34-2C1A-4B15-85CC-A99EA25C47D2}.Debug|Any CPU.Build.0 = Debug|Any CPU
{FC15CF34-2C1A-4B15-85CC-A99EA25C47D2}.Release|Any CPU.ActiveCfg = Release|Any CPU
{FC15CF34-2C1A-4B15-85CC-A99EA25C47D2}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -204,8 +216,10 @@ Global
{D3B72031-D4BD-44D3-973C-2752AB1570F6} = {84AD662A-4B9E-4E64-834D-72529FB7FCE5}
{2889E6B2-9CD1-437C-A43C-98CFAFF68B99} = {D59F1489-5D74-4F52-B78B-88037EAB2838}
{A9967817-2A2C-4C6D-A133-967A6062E9B3} = {75F709FD-8CC2-4558-A802-FE57086167C2}
{D9356867-0A30-4B17-BD4C-0F7EF70984C6} = {84AD662A-4B9E-4E64-834D-72529FB7FCE5}
{DC20ACF9-12E9-41D9-B672-CB5FD85548E9} = {84AD662A-4B9E-4E64-834D-72529FB7FCE5}
{4FC45D20-0BA9-484B-9040-641687659AF6} = {D59F1489-5D74-4F52-B78B-88037EAB2838}
{FC15CF34-2C1A-4B15-85CC-A99EA25C47D2} = {D59F1489-5D74-4F52-B78B-88037EAB2838}
{99E727A3-8EB3-437E-AAC8-3596E8B9B2AE} = {D59F1489-5D74-4F52-B78B-88037EAB2838}
{505421EC-2598-4114-B2EC-997959B89E74} = {84AD662A-4B9E-4E64-834D-72529FB7FCE5}
EndGlobalSection
Expand Down
3 changes: 3 additions & 0 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,22 @@
<PackageVersion Include="Microsoft.AspNetCore.Mvc.Testing" Version="9.0.1" />
<PackageVersion Include="Microsoft.AspNetCore.OData" Version="9.1.3" />
<PackageVersion Include="Microsoft.AspNetCore.OpenApi" Version="9.0.1" />
<PackageVersion Include="Microsoft.Azure.Cosmos" Version="3.46.1" />
<PackageVersion Include="Microsoft.EntityFrameworkCore" Version="9.0.1" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.Cosmos" Version="9.0.1" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.InMemory" Version="9.0.1" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.Proxies" Version="9.0.1" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.Sqlite" Version="9.0.1" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.SqlServer" Version="9.0.1" />
<PackageVersion Include="Microsoft.Extensions.Caching.Memory" Version="9.0.1" />
<PackageVersion Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="9.0.1" />
<PackageVersion Include="Microsoft.Extensions.Http" Version="9.0.1" />
<PackageVersion Include="Microsoft.Extensions.Logging.Abstractions" Version="9.0.1" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
<PackageVersion Include="Microsoft.OData.Core" Version="8.2.3" />
<PackageVersion Include="Microsoft.SourceLink.GitHub" Version="8.0.0" />
<PackageVersion Include="Microsoft.Spatial" Version="8.2.3" />
<PackageVersion Include="Newtonsoft.Json" Version="13.0.3" />
<PackageVersion Include="MongoDB.Driver" Version="3.1.0" />
<PackageVersion Include="NSubstitute" Version="5.3.0" />
<PackageVersion Include="NSwag.AspNetCore" Version="14.2.0" />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.12.35728.132
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sample.Datasync.Server.SingleContainer", "src\Sample.Datasync.Server.SingleContainer.csproj", "{5C9AB15D-EBE4-4F60-939C-B24E73F4174E}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Projects", "Projects", "{2410E728-3A10-4E61-BCE0-64031E9ABC1C}"
EndProject
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}"
EndProject
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}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{5C9AB15D-EBE4-4F60-939C-B24E73F4174E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5C9AB15D-EBE4-4F60-939C-B24E73F4174E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5C9AB15D-EBE4-4F60-939C-B24E73F4174E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5C9AB15D-EBE4-4F60-939C-B24E73F4174E}.Release|Any CPU.Build.0 = Release|Any CPU
{2CA5DC15-69DE-47EA-9FF3-595E6D6D9FB5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2CA5DC15-69DE-47EA-9FF3-595E6D6D9FB5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2CA5DC15-69DE-47EA-9FF3-595E6D6D9FB5}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2CA5DC15-69DE-47EA-9FF3-595E6D6D9FB5}.Release|Any CPU.Build.0 = Release|Any CPU
{98195FB2-DABA-48F6-8D52-50CF920B4F72}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{98195FB2-DABA-48F6-8D52-50CF920B4F72}.Debug|Any CPU.Build.0 = Debug|Any CPU
{98195FB2-DABA-48F6-8D52-50CF920B4F72}.Release|Any CPU.ActiveCfg = Release|Any CPU
{98195FB2-DABA-48F6-8D52-50CF920B4F72}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{2CA5DC15-69DE-47EA-9FF3-595E6D6D9FB5} = {2410E728-3A10-4E61-BCE0-64031E9ABC1C}
{98195FB2-DABA-48F6-8D52-50CF920B4F72} = {2410E728-3A10-4E61-BCE0-64031E9ABC1C}
EndGlobalSection
EndGlobal
58 changes: 58 additions & 0 deletions samples/datasync-server-cosmosdb-singlecontainer/infra/main.bicep
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

targetScope = 'subscription'

@minLength(1)
@maxLength(64)
@description('Name of the the environment which is used to generate a short unique hash used in all resources.')
param environmentName string

@minLength(1)
@description('Primary location for all resources')
param location string

@description('Optional - the name of the App Service to create. If not provided, a unique name will be generated.')
param appServiceName string = ''

@description('Optional - the name of the App Service Plan to create. If not provided, a unique name will be generated.')
param appServicePlanName string = ''

@description('Optional - the name of the Resource Group to create. If not provided, a unique name will be generated.')
param resourceGroupName string = ''

@description('Optional - the name for the CosmosDB account. If not provided, a unique name will be generated.')
param accountName string = ''

@description('Optional - the name for the database. default is TodoDb')
param databaseName string = 'TodoDb'

@description('Optional - the name for the container. default is TodoContainer.')
param containerName string = 'TodoContainer'

var resourceToken = toLower(uniqueString(subscription().id, environmentName, location))
var tags = { 'azd-env-name': environmentName }

resource resourceGroup 'Microsoft.Resources/resourceGroups@2022-09-01' = {
name: !empty(resourceGroupName) ? resourceGroupName : 'rg-${environmentName}'
location: location
tags: tags
}

module resources './resources.bicep' = {
name: 'resources'
scope: resourceGroup
params: {
location: location
tags: tags
appServiceName: !empty(appServiceName) ? appServiceName : 'app-${resourceToken}'
appServicePlanName: !empty(appServicePlanName) ? appServicePlanName : 'asp-${resourceToken}'
accountName: !empty(accountName) ? accountName : 'cdb-${resourceToken}'
databaseName: databaseName
containerName: containerName
}
}

output SERVICE_ENDPOINT string = resources.outputs.SERVICE_ENDPOINT

Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"environmentName": {
"value": "${AZURE_ENV_NAME}"
},
"location": {
"value": "${AZURE_LOCATION}"
}
}
}
142 changes: 142 additions & 0 deletions samples/datasync-server-cosmosdb-singlecontainer/infra/resources.bicep
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
targetScope = 'resourceGroup'

@minLength(1)
@description('Primary location for all resources')
param location string

@description('The name of the App Service to create.')
param appServiceName string

@description('The name of the App Service Plan to create.')
param appServicePlanName string

@description('The list of tags to apply to all resources.')
param tags object = {}

@description('The name for the CosmosDB account')
param accountName string

@description('The name for the database')
param databaseName string

@description('The name for the container')
param containerName string

resource account 'Microsoft.DocumentDB/databaseAccounts@2022-05-15' = {
name: toLower(accountName)
kind: 'GlobalDocumentDB'
location: location
properties: {
consistencyPolicy: {
defaultConsistencyLevel: 'Session'}
locations: [
{
locationName: location
}
]
databaseAccountOfferType: 'Standard'
}
}

resource database 'Microsoft.DocumentDB/databaseAccounts/sqlDatabases@2022-05-15' = {
parent: account
name: databaseName
properties: {
resource: {
id: databaseName
}
options: {
throughput: 1000
}
}
}

resource container 'Microsoft.DocumentDB/databaseAccounts/sqlDatabases/containers@2022-05-15' = {
parent: database
name: containerName
properties: {
resource: {
id: containerName
partitionKey: {
paths: [
'/entity'
]
kind: 'Hash'
}
indexingPolicy: {
indexingMode: 'consistent'
includedPaths: [
{
path: '/*'
}
]
excludedPaths: [
{
path: '/_etag/?'
}
]
compositeIndexes: [
[
{
path: '/updatedAt'
order: 'ascending'
}
{
path: '/id'
order: 'ascending'
}
]
]
}
}
}
}

resource appServicePlan 'Microsoft.Web/serverfarms@2022-09-01' = {
name: appServicePlanName
location: location
tags: tags
sku: {
name: 'B1'
capacity: 1
}
}

resource appService 'Microsoft.Web/sites@2022-09-01' = {
name: appServiceName
location: location
tags: union(tags, {
'azd-service-name': 'backend'
'hidden-related:${appServicePlan.id}': 'empty'
})
properties: {
httpsOnly: true
serverFarmId: appServicePlan.id
siteConfig: {
ftpsState: 'Disabled'
minTlsVersion: '1.2'
}
}

resource configLogs 'config' = {
name: 'logs'
properties: {
applicationLogs: { fileSystem: { level: 'Verbose' } }
detailedErrorMessages: { enabled: true }
failedRequestsTracing: { enabled: true }
httpLogs: { fileSystem: { retentionInMb: 35, retentionInDays: 3, enabled: true } }
}
}

resource connectionStrings 'config' = {
name: 'connectionstrings'
properties: {
DefaultConnection: {
value: account.listConnectionStrings().connectionStrings[0].connectionString
type: 'DocDb'
}
}
}
}

output SERVICE_ENDPOINT string = 'https://${appService.properties.defaultHostName}'
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using CommunityToolkit.Datasync.Server;
using Microsoft.AspNetCore.Mvc;
using Sample.Datasync.Server.SingleContainer.Models;

namespace Sample.Datasync.Server.Controllers;

[Route("tables/[controller]")]
public class TodoItemController : TableController<TodoItem>
{
public TodoItemController(IRepository<TodoItem> repository)
: base(repository)
{
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using CommunityToolkit.Datasync.Server;
using Microsoft.AspNetCore.Mvc;
using Sample.Datasync.Server.SingleContainer.Models;

namespace Sample.Datasync.Server.Controllers;

[Route("tables/[controller]")]
public class TodoListController : TableController<TodoList>
{
public TodoListController(IRepository<TodoList> repository) : base(repository)
{
Options = new TableControllerOptions { EnableSoftDelete = true };
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using CommunityToolkit.Datasync.Server.CosmosDb;
using System.ComponentModel.DataAnnotations;

namespace Sample.Datasync.Server.SingleContainer.Models;

public class TodoItem : CosmosTableData<TodoItem>
{
[Required, MinLength(1)]
public string Title { get; set; } = string.Empty;

public bool IsComplete { get; set; }
}
Loading