Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update code to read config from appconfig #5

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions azure.aspire.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: eShopLite
services:
app:
language: dotnet
project: .\eShopLite.AppHost\eShopLite.AppHost.csproj
host: containerapp
bindings:
- name: catalogservice2db
sourceType: containerapp
sourceResource: catalogservice
targetType: postgresql
targetResource: eshoppostgresql
storeType: appconfig
storeResource: eshopappcs
- name: basketservice2cache
sourceType: containerapp
sourceResource: basketservice
targetType: redis
targetResource: eshopredis
storeType: appconfig
storeResource: eshopappcs
- name: frontend2catalog
sourceType: containerapp
sourceResource: frontend
targetType: containerapp
targetResource: catalogservice
storeType: appconfig
storeResource: eshopappcs
- name: frontend2basket
sourceType: containerapp
sourceResource: frontend
targetType: containerapp
targetResource: basketservice
storeType: appconfig
storeResource: eshopappcs
- name: catalogappdb
sourceType: containerapp
sourceResource: catalogapp
targetType: postgresql
targetResource: eshoppostgresql
storeType: appconfig
storeResource: eshopappcs
3 changes: 2 additions & 1 deletion src/api/Program.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
using Azure.Identity;
using Microsoft.EntityFrameworkCore;
using SimpleTodo.Api;
using Microsoft.Extensions.Configuration.AzureAppConfiguration;

var builder = WebApplication.CreateBuilder(args);
var credential = new ChainedTokenCredential(new AzureDeveloperCliCredential(), new DefaultAzureCredential());
builder.Configuration.AddAzureKeyVault(new Uri(builder.Configuration["AZURE_KEY_VAULT_ENDPOINT"]), credential);
builder.Configuration.AddAzureAppConfiguration(builder.Configuration["AZURE_APP_CONFIGURATION_ENDPOINT"]);

builder.Services.AddScoped<ListsRepository>();
builder.Services.AddDbContext<TodoDb>(options =>
Expand Down
1 change: 1 addition & 0 deletions src/api/Todo.Api.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="6.0.1" />
<PackageReference Include="Microsoft.Data.SqlClient" Version="4.0.1" />
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.19.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.AzureAppConfiguration" Version="7.0.0" />
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerUI" Version="6.4.0" />
</ItemGroup>
</Project>