Skip to content

Commit

Permalink
Configure DB & Redis & add migration bundle
Browse files Browse the repository at this point in the history
  • Loading branch information
lwalther-ddog authored Jul 6, 2023
1 parent 954ca15 commit b8785af
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
7 changes: 7 additions & 0 deletions .github/workflows/main_msdocs-core-sql-lwp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,13 @@ jobs:
- name: dotnet publish
run: dotnet publish -c Release -o ${{env.DOTNET_ROOT}}/myapp

- name: dotnet ef
run: dotnet tool install -g dotnet-ef

- name: dotnet migration bundle
run: dotnet ef migrations bundle --runtime linux-x64 -p DotNetCoreSqlDb/DotNetCoreSqlDb.csproj -o ${{env.DOTNET_ROOT}}/myapp/migrate


- name: Upload artifact for deployment job
uses: actions/upload-artifact@v2
with:
Expand Down
9 changes: 6 additions & 3 deletions DotNetCoreSqlDb/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,12 @@

// Add database context and cache
builder.Services.AddDbContext<MyDatabaseContext>(options =>
options.UseSqlServer(builder.Configuration.GetConnectionString("MyDbConnection")));
builder.Services.AddDistributedMemoryCache();

options.UseSqlServer(builder.Configuration.GetConnectionString("AZURE_SQL_CONNECTIONSTRING")));
builder.Services.AddStackExchangeRedisCache(options =>
{
options.Configuration = builder.Configuration["AZURE_REDIS_CONNECTIONSTRING"];
options.InstanceName = "SampleInstance";
});
// Add services to the container.
builder.Services.AddControllersWithViews();

Expand Down
2 changes: 1 addition & 1 deletion DotNetCoreSqlDb/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
},
"AllowedHosts": "*",
"ConnectionStrings": {
"MyDbConnection": "Server=(localdb)\\mssqllocaldb;Database=MyDatabaseContext-ca7b86aa-ade2-4db1-a4a9-4dce925cb814;Trusted_Connection=True;MultipleActiveResultSets=true"
"MyDbConnection": "AZURE_SQL_CONNECTIONSTRING"
}
}

0 comments on commit b8785af

Please sign in to comment.