Environments Settings

Notes on working with multiple environments in a Wrapt project.

Multiple Environments

By default, Wrapt projects will have a Development environment. Wrapt templates are configured with a single startup file that will be used for all environments with the environment specific configurations below getting added as environment variables in a launch settings profile. This is will be enhanced in future releases to accommodate user secrets and other useful infrastructure scaffolding.

⚠️ You can scaffold as many environment profiles as you want, but it's recommended to only scaffold a Development profile. If you want to support additional environments, you can pass in new values to the environment variables as needed. I plan to have proper built in support for this in the future.

Environment Properties

NameRequiredDescriptionDefault
EnvironmentNameYesThe name of the environment. It's recommended to just do scaffolding for Development.None
ConnectionStringYes, if not DevelopmentNot needed for Development, but available if you need it. This is the connection string for the database. The connection string will just be added in between quotes and treated like a string, so will need to be valid in that format. Backslashes will automatically be escaped for you.local
ProfileNameNoThe name of the profile that is added into your launchsettings.json to run this environment.SOLUTIONNAME (Development)
AuthorityNoThe authority url for the auth server.None
AudienceNoThe unique id of the audience for an issued token (Identified in a JWT aud claim). In this case, this is usually going to be the identifier given to your API on your Authorization Server.None
AuthorizationUrlNoThe url to the authentication server to authenticate yourself and get an authorization code or access token.None
TokenUrlNoThe url to the authentication server to refresh your access token.None
ClientIdNoThe client id of the client as configured on your authorization server.None
ClientSecretNoThe client secret known only to your application and authorization server.None
BrokerSettingsNoThe settings for the message broker, if you are adding one.None

Broker Settings

NameRequiredDescriptionDefault
HostYesThe host for the broker connectionlocalhost
VirtualHostYesThe virtual host of the broker. This provides a way to segregate applications using the same RabbitMQ instance./
UsernameYesThe username for the broker connectionguest
PasswordYesThe password for the broker connection.guest

⚠️ IMPORTANT: Note that the connection strings, broker passwords, and client secrets will currently be added to launchsettings.json and will, in turn, be committed to source control. You should NOT be adding anything with credentials in here. As mentioned above, it is only recommended to scaffold a Development profile, which is generally ran locally and doesn't have sensitive material, but in case it does, you should be aware of this.

Example Setting Up Multiple Environments

A Development environment will be created for us automatically. In this example, we are also setting up a Local environment so we can run our api locally against a real database. With that said, you'd also have the option to just modify your database registration to point to your local database instead of the in memory one.

Environments:
  - EnvironmentName: Local
    ConnectionString: "Data Source=mylocaldb;Initial Catalog=MyDbName;Integrated Security=True;Encrypt=True;TrustServerCertificate=True;"
    ProfileName: Local

Example with Auth and Broker Settings

In this example, we are not adding any new environments, but adding auth and broker info for Development (our local, in memory project).

  Environments:
  - EnvironmentName: Development
    Authority: https://localhost:5010
    Audience: patients
    AuthorizationUrl: https://localhost:5010/connect/authorize
    TokenUrl: https://localhost:5010/connect/token
    ClientId: swagger
    BrokerSettings:
      Host: localhost
      VirtualHost: /
      Username: guest
      Password: guest
  - EnvironmentName: Production
    BrokerSettings:
      Host: rmqlocalprod
      VirtualHost: dashprod
      Username: testprod
      Password: testprod

At the moment, if you are connecting to anything outside of development, you may need to make some tweaks to include SSL and a port. For example, this CloudAMQP connection:

cfg.Host("baboon.rmq.cloudamqp.com", 8983, "kalvak", h =>
{
    h.Username("kalvak:kalvak");
    h.Password("supersecretpassword");

    h.UseSsl(s =>
    {
        s.Protocol = SslProtocols.Tls12;
    });
});