Skip to content

Commit

Permalink
Configure Azure database and cache connections
Browse files Browse the repository at this point in the history
  • Loading branch information
nitin27verma committed Dec 1, 2024
1 parent 16fce90 commit 1dedb68
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 19 deletions.
24 changes: 15 additions & 9 deletions .github/workflows/starter-no-infra_dev-4u4qhiztjanba.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@ jobs:
- name: dotnet publish
run: dotnet publish -c Release -o ${{env.DOTNET_ROOT}}/myapp

- name: nstall dotnet ef
run: dotnet tool install -g dotnet-ef --version 8.*

- name: Create migration bundle
run: dotnet ef migrations bundle --runtime linux-x64 -o ${{env.DOTNET_ROOT}}/myapp/migrationsbundle

- name: Upload artifact for deployment job
uses: actions/upload-artifact@v4
with:
Expand All @@ -39,21 +45,21 @@ jobs:
environment:
name: 'Production'
url: ${{ steps.deploy-to-webapp.outputs.webapp-url }}
permissions:
id-token: write #This is required for requesting the JWT
permissions:
id-token: write #This is required for requesting the JWT

steps:
- name: Download artifact from build job
uses: actions/download-artifact@v4
with:
name: .net-app

- name: Login to Azure
uses: azure/login@v2
with:
client-id: ${{ secrets.AZUREAPPSERVICE_CLIENTID_319DDE8D9F4B4C74A9AB966B051D210E }}
tenant-id: ${{ secrets.AZUREAPPSERVICE_TENANTID_AF081E3B8DC54CBAB41CE97FFE6A6307 }}
subscription-id: ${{ secrets.AZUREAPPSERVICE_SUBSCRIPTIONID_01AC867E738A4C3DBBC0E2E51A4BF863 }}

- name: Login to Azure
uses: azure/login@v2
with:
client-id: ${{ secrets.AZUREAPPSERVICE_CLIENTID_319DDE8D9F4B4C74A9AB966B051D210E }}
tenant-id: ${{ secrets.AZUREAPPSERVICE_TENANTID_AF081E3B8DC54CBAB41CE97FFE6A6307 }}
subscription-id: ${{ secrets.AZUREAPPSERVICE_SUBSCRIPTIONID_01AC867E738A4C3DBBC0E2E51A4BF863 }}

- name: Deploy to Azure Web App
id: deploy-to-webapp
Expand Down
20 changes: 10 additions & 10 deletions Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@
options.UseSqlServer(builder.Configuration.GetConnectionString("MyDbConnection")));
builder.Services.AddDistributedMemoryCache();
}
// else
// {
// builder.Services.AddDbContext<MyDatabaseContext>(options =>
// options.UseSqlServer(builder.Configuration.GetConnectionString("AZURE_SQL_CONNECTIONSTRING")));
// builder.Services.AddStackExchangeRedisCache(options =>
// {
// options.Configuration = builder.Configuration["AZURE_REDIS_CONNECTIONSTRING"];
// options.InstanceName = "SampleInstance";
// });
// }
else
{
builder.Services.AddDbContext<MyDatabaseContext>(options =>
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

0 comments on commit 1dedb68

Please sign in to comment.