Skip to content

Commit 342546a

Browse files
committed
Configure Azure database and cache connections
1 parent af07054 commit 342546a

File tree

2 files changed

+25
-19
lines changed

2 files changed

+25
-19
lines changed

.github/workflows/starter-no-infra_msdocs-core-sql-bkr.yml

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,12 @@ jobs:
2727
- name: dotnet publish
2828
run: dotnet publish -c Release -o ${{env.DOTNET_ROOT}}/myapp
2929

30+
- name: Install dotnet ef
31+
run: dotnet tool install -g dotnet-ef --version 8.*
32+
33+
- name: Create migrations bundle
34+
run: dotnet ef migrations bundle --runtime linux-x64 -o ${{env.DOTNET_ROOT}}/myapp/migrationsbundle
35+
3036
- name: Upload artifact for deployment job
3137
uses: actions/upload-artifact@v4
3238
with:
@@ -39,21 +45,21 @@ jobs:
3945
environment:
4046
name: 'Production'
4147
url: ${{ steps.deploy-to-webapp.outputs.webapp-url }}
42-
permissions:
43-
id-token: write #This is required for requesting the JWT
48+
permissions:
49+
id-token: write #This is required for requesting the JWT
4450

4551
steps:
4652
- name: Download artifact from build job
4753
uses: actions/download-artifact@v4
4854
with:
4955
name: .net-app
50-
51-
- name: Login to Azure
52-
uses: azure/login@v2
53-
with:
54-
client-id: ${{ secrets.AZUREAPPSERVICE_CLIENTID_35BD3300570A468CAD1821F29FB6EA6F }}
55-
tenant-id: ${{ secrets.AZUREAPPSERVICE_TENANTID_AA47BBAF1358488B9F8FBF2D13596B4F }}
56-
subscription-id: ${{ secrets.AZUREAPPSERVICE_SUBSCRIPTIONID_047C3DAF5D6A43F5820F945416A215E8 }}
56+
57+
- name: Login to Azure
58+
uses: azure/login@v2
59+
with:
60+
client-id: ${{ secrets.AZUREAPPSERVICE_CLIENTID_35BD3300570A468CAD1821F29FB6EA6F }}
61+
tenant-id: ${{ secrets.AZUREAPPSERVICE_TENANTID_AA47BBAF1358488B9F8FBF2D13596B4F }}
62+
subscription-id: ${{ secrets.AZUREAPPSERVICE_SUBSCRIPTIONID_047C3DAF5D6A43F5820F945416A215E8 }}
5763

5864
- name: Deploy to Azure Web App
5965
id: deploy-to-webapp

Program.cs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,16 @@
99
options.UseSqlServer(builder.Configuration.GetConnectionString("MyDbConnection")));
1010
builder.Services.AddDistributedMemoryCache();
1111
}
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-
// }
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+
}
2222

2323
// Add services to the container.
2424
builder.Services.AddControllersWithViews();

0 commit comments

Comments
 (0)