Notes on working with multiple environments in a Wrapt project.
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.
Name | Required | Description | Default |
---|---|---|---|
EnvironmentName | Yes | The name of the environment. It's recommended to just do scaffolding for Development . | None |
ConnectionString | Yes, if not Development | Not 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 |
ProfileName | No | The name of the profile that is added into your launchsettings.json to run this environment. | SOLUTIONNAME (Development) |
Authority | No | The authority url for the auth server. | None |
Audience | No | The 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 |
AuthorizationUrl | No | The url to the authentication server to authenticate yourself and get an authorization code or access token. | None |
TokenUrl | No | The url to the authentication server to refresh your access token. | None |
ClientId | No | The client id of the client as configured on your authorization server. | None |
ClientSecret | No | The client secret known only to your application and authorization server. | None |
BrokerSettings | No | The settings for the message broker, if you are adding one. | None |
Name | Required | Description | Default |
---|---|---|---|
Host | Yes | The host for the broker connection | localhost |
VirtualHost | Yes | The virtual host of the broker. This provides a way to segregate applications using the same RabbitMQ instance. | / |
Username | Yes | The username for the broker connection | guest |
Password | Yes | The 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 aDevelopment
profile, which is generally ran locally and doesn't have sensitive material, but in case it does, you should be aware of this.
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
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;
});
});