In order to run this app locally, I encourage reading through this article. There are a few optional configuration values that can make the local developer experience much more enjoyable.
This value is optional to configure. If you do not configure it, however; be sure not to run the Web.Functions
as mentioned in the Running the app section. The WeatherComponent
in the Web.Client
project will still attempt to request weather data, but it will be represented as unavailable. In order to use weather, sign up for an API account.
I personally use the free version.
Key | Data type | Default value |
---|---|---|
OpenWeatherMapOptions__ApiKey |
string |
null |
This configuration is required to run the app.
Key | Data type | Default value |
---|---|---|
HibpOptions__ApiKey |
string |
null |
HibpOptions__UserAgent |
string |
".NET HIBP Client/{AssemblyFileVersion}" |
This specific API key isn't free, if you'd rather not sign up for the API, you can use the following API key to enable a demo mode I've built into the application to show how a feature toggle might work in Blazor:
"HibpOptions": {
"ApiKey": "demo"
}
This could be configured in the appsettings.Development.json file of the Web.PwnedApi project. Alternatively, the demo mode can be enabled by setting the HibpOptions__ApiKey
environment variable to demo
.
For more information, see ';-- have i been pwned? — .NET HTTP client..
These configurations are optional, but if you do not set them the Contact page in the Web.Client
project will not be able to send email. The /contact
uses a Logic App endpoint to send an email. In order for the app to correctly send this email, the app expects the following config value:
Key | Data type | Default value |
---|---|---|
LogicAppOptions__ContactUrl |
string |
null |
For more information, see Microsoft Azure: Create Logic App.
The shape of the HTTP post body:
{
"firstName": "David",
"lastName": "Pine",
"fromEmail": "example@email.org",
"subject": "Just want'ed to say \"Hi\"!",
"body": "... but now I'm a bit nervous."
}
The app is architected into microservices.
- The
Web.Client
project is the Blazor WebAssembly client app. - The
Web.Api
project is a Web API project with. - The
Web.PwnedApi
project is a Minimal API project. - The
Web.Functions
project is an Azure Functions app.
All of these need to be started. The Web.Client
relies on the other three project's APIs.
They need to be started before the Web.Client
app. Add (or update) each project's launchSetting.json file:
Save the ./src/Web.Client/Properties/launchSettings.json as follows:
{
"profiles": {
"Web.Client": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}",
"applicationUrl": "https://localhost:5001",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}
Save the ./src/Web.Api/Properties/launchSettings.json as follows:
{
"profiles": {
"Web.Api": {
"commandName": "Project",
"launchBrowser": false,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"applicationUrl": "https://localhost:5002"
}
}
}
Save the ./src/Web.PwnedApi/Properties/launchSettings.json as follows:
{
"profiles": {
"Web.PwnedApi": {
"commandName": "Project",
"launchBrowser": false,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"applicationUrl": "https://localhost:5003"
}
}
}
Save the ./src/Web.Functions/local.settings.json as follows:
{
"IsEncrypted": false,
"Values": {
"AzureWebJobsStorage": "",
"FUNCTIONS_WORKER_RUNTIME": "dotnet"
},
"Host": {
"LocalHttpPort": 5004,
"CORS": "*",
"CORSCredentials": false
}
}
If you're using Visual Studio, right-click the solution file in the Solution Exporer. From the context menu select Set Startup Projects.
If configured correctly, you'll have four console apps running:
https://localost:5001
: Web.Client — ASP.NET Core Blazor WebAssembly project.https://localost:5002
: Web.Api — ASP.NET Core Web API project.https://localost:5003
: Web.PwnedApi — ASP.NET Core Minimal API project.https://localost:5004
: Web.Functions — Azure Functions, .NET & HTTP triggered project.