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
gathogojr authored May 31, 2024
1 parent 5df92da commit 088a766
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 11 deletions.
24 changes: 15 additions & 9 deletions .github/workflows/main_msdocs-dotnetcore-sql-jrg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ jobs:
- name: dotnet publish
run: dotnet publish -c Release -o ${{env.DOTNET_ROOT}}/myapp

- name: Install dotnet ef tool
run: dotnet tool install -g dotnet-ef --version 8.0.6

- name: Generate dotnet ef 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@v3
with:
Expand All @@ -40,21 +46,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@v3
with:
name: .net-app

- name: Login to Azure
uses: azure/login@v1
with:
client-id: ${{ secrets.AZUREAPPSERVICE_CLIENTID_A4F22D581CD0485BB97182E8747AAD26 }}
tenant-id: ${{ secrets.AZUREAPPSERVICE_TENANTID_9FE14E41A98340FEA5FD5BA1FD7D0676 }}
subscription-id: ${{ secrets.AZUREAPPSERVICE_SUBSCRIPTIONID_0CD9FF206BB04E40AAB733AA86B144BE }}

- name: Login to Azure
uses: azure/login@v1
with:
client-id: ${{ secrets.AZUREAPPSERVICE_CLIENTID_A4F22D581CD0485BB97182E8747AAD26 }}
tenant-id: ${{ secrets.AZUREAPPSERVICE_TENANTID_9FE14E41A98340FEA5FD5BA1FD7D0676 }}
subscription-id: ${{ secrets.AZUREAPPSERVICE_SUBSCRIPTIONID_0CD9FF206BB04E40AAB733AA86B144BE }}

- name: Deploy to Azure Web App
id: deploy-to-webapp
Expand Down
2 changes: 1 addition & 1 deletion DotNetCoreSqlDb/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

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

// Add services to the container.
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"
"AZURE_SQL_CONNECTIONSTRING": "Server=(localdb)\\mssqllocaldb;Database=MyDatabaseContext-ca7b86aa-ade2-4db1-a4a9-4dce925cb814;Trusted_Connection=True;MultipleActiveResultSets=true"
}
}

0 comments on commit 088a766

Please sign in to comment.