Skip to content

Latest commit

 

History

History
167 lines (125 loc) · 5.64 KB

GET_STARTED.md

File metadata and controls

167 lines (125 loc) · 5.64 KB

Get Started

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.

Configure Open Weather Map API

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

Configure Have I Been Pwned API

This configuration is required to run the app.

Key Data type Default value
HibpOptions__ApiKey string null
HibpOptions__UserAgent string ".NET HIBP Client/{AssemblyFileVersion}"

⚠️ NOTE:
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..

NuGet

Configure Logic App

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": "[email protected]",
    "subject": "Just want'ed to say \"Hi\"!",
    "body": "... but now I'm a bit nervous."
}

Running the app

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:

Web.Client

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"
      }
    }
  }
}

Web.Api

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"
    }
  }
}

Web.PwnedApi

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"
    }
  }
}

Web.Functions

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.

Visual Studio: Web.Client solution properties dialog.

Web Server, Services and Client apps

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.