diff --git a/Contacts.API/Contacts.API.csproj b/Contacts.API/Contacts.API.csproj index 9d1d800..1bbed8b 100644 --- a/Contacts.API/Contacts.API.csproj +++ b/Contacts.API/Contacts.API.csproj @@ -6,10 +6,11 @@ - + - - + + + diff --git a/Contacts.API/Startup.cs b/Contacts.API/Startup.cs index f49a152..bc39cfb 100644 --- a/Contacts.API/Startup.cs +++ b/Contacts.API/Startup.cs @@ -19,6 +19,7 @@ using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; using Microsoft.OpenApi.Models; +using AutoMapper; namespace Contacts.API; @@ -53,7 +54,7 @@ public void ConfigureServices(IServiceCollection services) ContactPartitionKeyProvider partitionKeyProvider = new(); - services.AddAutoMapper(typeof(ContactsProfile)); + services.AddAutoMapper(cfg => { }, typeof(ContactsProfile)); services.AddValidatorsFromAssembly(typeof(CreateContactCommandValidator).Assembly); services.AddSingleton(container) diff --git a/Contacts.Application/Contacts.Application.csproj b/Contacts.Application/Contacts.Application.csproj index ddd2008..1e5f44d 100644 --- a/Contacts.Application/Contacts.Application.csproj +++ b/Contacts.Application/Contacts.Application.csproj @@ -5,9 +5,10 @@ - - - + + + + diff --git a/Contacts.Domain/Contacts.Domain.csproj b/Contacts.Domain/Contacts.Domain.csproj index 85baa00..b89bf78 100644 --- a/Contacts.Domain/Contacts.Domain.csproj +++ b/Contacts.Domain/Contacts.Domain.csproj @@ -5,8 +5,8 @@ - - + + diff --git a/Contacts.EventsProcessor/Contacts.EventsProcessor.csproj b/Contacts.EventsProcessor/Contacts.EventsProcessor.csproj index 831cd04..4c42bc9 100644 --- a/Contacts.EventsProcessor/Contacts.EventsProcessor.csproj +++ b/Contacts.EventsProcessor/Contacts.EventsProcessor.csproj @@ -7,8 +7,9 @@ - - - + + + + diff --git a/Contacts.Infrastructure/Contacts.Infrastructure.csproj b/Contacts.Infrastructure/Contacts.Infrastructure.csproj index 2470800..9c09030 100644 --- a/Contacts.Infrastructure/Contacts.Infrastructure.csproj +++ b/Contacts.Infrastructure/Contacts.Infrastructure.csproj @@ -1,8 +1,9 @@ - - + + + diff --git a/Contacts.Tests/Contacts.Tests.csproj b/Contacts.Tests/Contacts.Tests.csproj index 7633b90..7bac47e 100644 --- a/Contacts.Tests/Contacts.Tests.csproj +++ b/Contacts.Tests/Contacts.Tests.csproj @@ -7,21 +7,22 @@ - - - - - - - - + + + + + + + + + - + runtime; build; native; contentfiles; analyzers; buildtransitive all - + runtime; build; native; contentfiles; analyzers; buildtransitive all diff --git a/Deployment/deploy.bicep b/Deployment/deploy.bicep index b651534..0ddd761 100644 --- a/Deployment/deploy.bicep +++ b/Deployment/deploy.bicep @@ -1,7 +1,7 @@ param location string = resourceGroup().location // Cosmos DB Account -resource cosmosDbAccount 'Microsoft.DocumentDB/databaseAccounts@2024-05-15' = { +resource cosmosDbAccount 'Microsoft.DocumentDB/databaseAccounts@2025-04-15' = { name: 'cosmos-tobp-${uniqueString(resourceGroup().id)}' location: location kind: 'GlobalDocumentDB' @@ -22,7 +22,7 @@ resource cosmosDbAccount 'Microsoft.DocumentDB/databaseAccounts@2024-05-15' = { } // Cosmos DB -resource cosmosDbDatabase 'Microsoft.DocumentDB/databaseAccounts/sqlDatabases@2024-05-15' = { +resource cosmosDbDatabase 'Microsoft.DocumentDB/databaseAccounts/sqlDatabases@2025-04-15' = { parent: cosmosDbAccount name: 'tobp' location: location @@ -39,7 +39,7 @@ resource cosmosDbDatabase 'Microsoft.DocumentDB/databaseAccounts/sqlDatabases@20 } // Data Container -resource containerData 'Microsoft.DocumentDB/databaseAccounts/sqlDatabases/containers@2024-05-15' = { +resource containerData 'Microsoft.DocumentDB/databaseAccounts/sqlDatabases/containers@2025-04-15' = { parent: cosmosDbDatabase name: 'data' location: location @@ -72,7 +72,7 @@ resource containerData 'Microsoft.DocumentDB/databaseAccounts/sqlDatabases/conta } // Leases Container -resource containerLeases 'Microsoft.DocumentDB/databaseAccounts/sqlDatabases/containers@2024-05-15' = { +resource containerLeases 'Microsoft.DocumentDB/databaseAccounts/sqlDatabases/containers@2025-04-15' = { parent: cosmosDbDatabase name: 'leases' location: location @@ -104,7 +104,7 @@ resource containerLeases 'Microsoft.DocumentDB/databaseAccounts/sqlDatabases/con } // ServiceBus -resource sb 'Microsoft.ServiceBus/namespaces@2021-11-01' = { +resource sb 'Microsoft.ServiceBus/namespaces@2024-01-01' = { name: 'sb-tobp-${uniqueString(resourceGroup().id)}' location: location sku: { @@ -126,7 +126,7 @@ resource sb 'Microsoft.ServiceBus/namespaces@2021-11-01' = { enableExpress: false } - resource sbtTestSubscription 'subscriptions@2021-11-01' = { + resource sbtTestSubscription 'subscriptions@2024-01-01' = { name: 'testSubscription' properties: { lockDuration: 'PT5M' @@ -141,18 +141,9 @@ resource sb 'Microsoft.ServiceBus/namespaces@2021-11-01' = { } } -// Storage Account for Function -resource stgForFunctions 'Microsoft.Storage/storageAccounts@2023-05-01' = { - name: 'stfn${take(uniqueString(resourceGroup().id), 11)}' - location: location - kind: 'StorageV2' - sku: { - name: 'Standard_LRS' - } -} // ApplicationInsights -resource workspace 'Microsoft.OperationalInsights/workspaces@2023-09-01' = { +resource workspace 'Microsoft.OperationalInsights/workspaces@2025-02-01' = { name: 'ws-tobp-${uniqueString(resourceGroup().id)}' location: location properties: { @@ -172,34 +163,52 @@ resource appi 'Microsoft.Insights/components@2020-02-02' = { } } -// Dynamic Hostingplan -resource hostingPlan 'Microsoft.Web/serverfarms@2023-12-01' = { - name: 'plan-tobp-${uniqueString(resourceGroup().id)}' +// Storage Account for Azure Function +resource storageAccount 'Microsoft.Storage/storageAccounts@2025-01-01' = { + name: 'st${replace(uniqueString(resourceGroup().id), '-', '')}' + location: location + sku: { + name: 'Standard_LRS' + } + kind: 'StorageV2' + properties: { + accessTier: 'Hot' + } +} + +// App Service Plan for Azure Function +resource functionAppServicePlan 'Microsoft.Web/serverfarms@2024-11-01' = { + name: 'asp-func-tobp-${uniqueString(resourceGroup().id)}' location: location sku: { name: 'Y1' tier: 'Dynamic' } - properties: {} + properties: { + reserved: false + } } -// Function App -resource functionApp 'Microsoft.Web/sites@2023-12-01' = { - name: 'funcapp-tobp-${uniqueString(resourceGroup().id)}' +// Azure Function App +resource functionApp 'Microsoft.Web/sites@2024-11-01' = { + name: 'func-tobp-${uniqueString(resourceGroup().id)}' location: location kind: 'functionapp' properties: { - httpsOnly: true - serverFarmId: hostingPlan.id + serverFarmId: functionAppServicePlan.id siteConfig: { appSettings: [ { - name: 'APPINSIGHTS_INSTRUMENTATIONKEY' - value: appi.properties.InstrumentationKey + name: 'AzureWebJobsStorage' + value: 'DefaultEndpointsProtocol=https;AccountName=${storageAccount.name};EndpointSuffix=${environment().suffixes.storage};AccountKey=${storageAccount.listKeys().keys[0].value}' } { - name: 'AzureWebJobsStorage' - value: 'DefaultEndpointsProtocol=https;AccountName=${stgForFunctions.name};EndpointSuffix=${environment().suffixes.storage};AccountKey=${stgForFunctions.listKeys().keys[0].value}' + name: 'WEBSITE_CONTENTAZUREFILECONNECTIONSTRING' + value: 'DefaultEndpointsProtocol=https;AccountName=${storageAccount.name};EndpointSuffix=${environment().suffixes.storage};AccountKey=${storageAccount.listKeys().keys[0].value}' + } + { + name: 'WEBSITE_CONTENTSHARE' + value: toLower('func-tobp-${uniqueString(resourceGroup().id)}') } { name: 'FUNCTIONS_EXTENSION_VERSION' @@ -207,54 +216,53 @@ resource functionApp 'Microsoft.Web/sites@2023-12-01' = { } { name: 'FUNCTIONS_WORKER_RUNTIME' - value: 'dotnet' + value: 'dotnet-isolated' } { - name: 'SERVICEBUS_CONNECTION' - value: '${listKeys('${sb.id}/AuthorizationRules/RootManageSharedAccessKey', sb.apiVersion).primaryConnectionString}' + name: 'APPINSIGHTS_INSTRUMENTATIONKEY' + value: appi.properties.InstrumentationKey } { - name: 'WEBSITE_CONTENTAZUREFILECONNECTIONSTRING' - value: 'DefaultEndpointsProtocol=https;AccountName=${stgForFunctions.name};EndpointSuffix=${environment().suffixes.storage};AccountKey=${stgForFunctions.listKeys().keys[0].value}' + name: 'APPLICATIONINSIGHTS_CONNECTION_STRING' + value: appi.properties.ConnectionString + } + { + name: 'Cosmos:Url' + value: 'https://${cosmosDbAccount.name}.documents.azure.com:443/' + } + { + name: 'Cosmos:Key' + value: listKeys('${cosmosDbAccount.id}', cosmosDbAccount.apiVersion).primaryMasterKey } - ] - } - } -} - -// Function -resource function 'Microsoft.Web/sites/functions@2023-12-01' = { - parent: functionApp - name: 'funcapp-tobp-${uniqueString(resourceGroup().id)}' - properties: { - function_app_id: functionApp.id - config: { - bindings: [ { - name: 'mySbMsg' - type: 'serviceBusTrigger' - direction: 'in' - topicName: 'sbt-contacts' - subscriptionName: 'testSubscription' - connection: 'SERVICEBUS_CONNECTION' - isSessionsEnabled: true + name: 'Cosmos:Db' + value: 'tobp' + } + { + name: 'Cosmos:Container' + value: 'data' + } + { + name: 'Events:Ttl' + value: '864000' + } + { + name: 'ServiceBus:ConnectionString' + value: listKeys('${sb.id}/AuthorizationRules/RootManageSharedAccessKey', sb.apiVersion).primaryConnectionString } ] + netFrameworkVersion: 'v8.0' + use32BitWorkerProcess: false + cors: { + allowedOrigins: [ + 'https://portal.azure.com' + ] + } } - files: { - 'run.csx': '''using System; -using System.Threading.Tasks; - -public static void Run(string mySbMsg, ILogger log) -{ - log.LogInformation($"C# ServiceBus topic trigger function processed message: {mySbMsg}"); -}''' - } - } } -resource appServicePlan 'Microsoft.Web/serverfarms@2023-12-01' = { +resource appServicePlan 'Microsoft.Web/serverfarms@2024-11-01' = { name: 'appservice-tobp-${uniqueString(resourceGroup().id)}' location: location sku: { @@ -264,7 +272,7 @@ resource appServicePlan 'Microsoft.Web/serverfarms@2023-12-01' = { properties: {} } -resource appService 'Microsoft.Web/sites@2023-12-01' = { +resource appService 'Microsoft.Web/sites@2024-11-01' = { name: 'webapp-tobp-${uniqueString(resourceGroup().id)}' location: location properties: { @@ -309,3 +317,4 @@ output cosmosUri string = 'https://${cosmosDbAccount.name}.documents.azure.com:4 output cosmosDbName string = 'tobp' output cosmosDbDataContainerName string = 'data' output cosmosDbLeasesContainerName string = 'leases' +output functionAppName string = functionApp.name diff --git a/global.json b/global.json index 3ce70d9..f87736c 100644 --- a/global.json +++ b/global.json @@ -1,6 +1,6 @@ { "sdk": { - "version": "8.0.0", + "version": "8.0.413", "rollForward": "minor", "allowPrerelease": false }