File tree Expand file tree Collapse file tree 2 files changed +17
-8
lines changed
Expand file tree Collapse file tree 2 files changed +17
-8
lines changed Original file line number Diff line number Diff line change 11using Microsoft . EntityFrameworkCore ;
2- using Microsoft . Extensions . DependencyInjection ;
32using DotNetCoreSqlDb . Data ;
43var builder = WebApplication . CreateBuilder ( args ) ;
54
65// Add database context and cache
7- builder . Services . AddDbContext < MyDatabaseContext > ( options =>
8- options . UseSqlServer ( builder . Configuration . GetConnectionString ( "AZURE_SQL_CONNECTIONSTRING" ) ) ) ;
9- builder . Services . AddStackExchangeRedisCache ( options =>
6+ if ( builder . Environment . IsDevelopment ( ) )
107{
11- options . Configuration = builder . Configuration [ "AZURE_REDIS_CONNECTIONSTRING" ] ;
12- options . InstanceName = "SampleInstance" ;
13- } ) ;
8+ builder . Services . AddDbContext < MyDatabaseContext > ( options =>
9+ options . UseSqlServer ( builder . Configuration . GetConnectionString ( "MyDbConnection" ) ) ) ;
10+ builder . Services . AddDistributedMemoryCache ( ) ;
11+ }
12+ else
13+ {
14+ builder . Services . AddDbContext < MyDatabaseContext > ( options =>
15+ options . UseSqlServer ( builder . Configuration . GetConnectionString ( "AZURE_SQL_CONNECTIONSTRING" ) ) ) ;
16+ builder . Services . AddStackExchangeRedisCache ( options =>
17+ {
18+ options . Configuration = builder . Configuration [ "AZURE_REDIS_CONNECTIONSTRING" ] ;
19+ options . InstanceName = "SampleInstance" ;
20+ } ) ;
21+ }
22+
1423
1524// Add services to the container.
1625builder . Services . AddControllersWithViews ( ) ;
Original file line number Diff line number Diff line change @@ -252,7 +252,7 @@ resource web 'Microsoft.Web/sites@2022-09-01' = {
252252 linuxFxVersion : 'DOTNETCORE|8.0' // Set to .NET 8 (LTS)
253253 vnetRouteAllEnabled : true // Route outbound traffic to the VNET
254254 ftpsState : 'Disabled'
255- appCommandLine : './migrationsbundle && dotnet "DotNetCoreSqlDb.dll"'
255+ appCommandLine : './migrationsbundle -- --environment Production && dotnet "DotNetCoreSqlDb.dll"'
256256 }
257257 serverFarmId : appServicePlan .id
258258 httpsOnly : true
You can’t perform that action at this time.
0 commit comments