Skip to content

Deployment Parameters

Jonas Van der Biest edited this page Sep 18, 2016 · 15 revisions

Lunchorder is one of the first big projects we developed on a public Github repo. This brings some challenges with sensitive data that should not be included with our sources. The first paragraph gives an overview of all parameters you can set, the next paragraph digs deeper on how we implemented this.

Parameters

Backend

These are set in backend/WebApi/LunchOrder.Api/web.config.release

application - company

application details are displayed in application and emails

__companyName__: the name of your company

__companyPhone__: an optional phone number of your company

__companyWebsite__: an optional website of your company

application - address

__addressStreet__: the delivery address of your company

__addressNumber__: the delivery address number of your company

__addressPostalCode__: the delivery postal code of your company

__addressCity__: the delivery city of your company

authentication - apiKeys

an api key can be used to access certain api operations without an active user authentication. Useful to trigger operations with remote services __apiKey1__: an api key

authentication - local

__localAudience__: the audience to use when using local user authentication

__localAudienceSecret__: the secret key to create tokens when local user authentication

__localIssuer__: a URI to identify your application

authentication - azure

__azureTenant__: the Windows Azure Active Directory you are using (ex. codit.onmicrosoft.com)

__azureAudience__: the id of your WAAD client application

connections - documentDb

__documentDbEndpoint__: the URI of your document db server

__documentDbAuthKey__: the secret key to access your document db server

__documentDbDatabase__: the database to use for document db

__documentDbCollection__: the collection to use for document db

connections - azureStorage

__azureStorageConnectionString__: the connectionstring to an azure blob account (format: DefaultEndpointsProtocol=https;AccountName=YOURACCOUNT;AccountKey=YOURACCOUNTKEY)

__azureStorageImageContainerName__: the name of the image container

eventing

eventing is used to call 3rd party libraries to send events to.

__servicebusEnabled__: enables Microsft Azure servicebus

__servicebusConnectionString__: the connectionstring to Microsft Azure Servicebus

__servicebusTopic__: the name of the topic to send events to

email

to send emails from the platform, we currently only support sendgrid (free service) __sendgridApiKey__: the api key to authorize with sendgrid

__sendgridFrom__: the 'from' address field when sending emails

__sendgridBcc__: the 'bcc' address field when sending emails. You can specify multiple (ex@amp.le;you@read-th.is).

jobs

jobs will run in the background of the application. Remember to make sure your application is configured to "Run Always" (IIS setting).

__backupJobEnabled__: backups documentDb database

__emailJobEnabled__: send out email to vendor at specific order time

Frontend

These are set in frontend/app/services/configService.ts.params Note that there are 4 underscores (prefix and suffix), because in our generated js bundle there are variables with 2 underscores

____allowWeekendOrders____: allow weekend orders in front-end, leave empty for false

____configTenant____: the tenant to use for WAAD

____configClientId____: the id of your WAAD client application

____activeDirectoryEnabled____: enables windows azure active directory login, leave empty for false

____usernamePasswordEnabled____: enables user password authentication, leave empty for false

____isDemo____: enables demo instructions, leave empty for false

____demoAdmin____: displayed login for administrator

____demoAdminPass____: displayed password for administrator

____demoUser____: displayed login for user

____demoUserPass____: displayed password for user

Implementation

We have to support development and build servers to easily set parameters.

Backend

In WebApi, we have some experience with web.config transformations but they only work when publishing a project (good for build server), but not for building a project (what happens with development). So the first thing we needed to tackle is to perform transformations on build. This can be done by adding a custom task to our project file. Transformations are useful as they replace your web.config file with parameters based on the current build configuration. So in our web.base.config, we have empty values. Using transformations, our web.release.config parameters will be tranformed to web.base.config and that file will be renamed to web.config. The same happens with web.debug.config but this file will contain our sensitive parameter data. The web.debug.config and the generated web.config file is excluded from github.

Frontend

For frontend we don't really know what's the best solution. We didn't find any good articles about parameter replacement in javascript (or typescript) sources.

In Angular2 we will have 1 configurationService that will hold all parameters. Everything in one file would be a good start. The problem is that the actual typescript file needs to be overwritten before transpilation to include the parameterized values. The modified file can potentially be checked in to Github. Not what we want.

So the solution is to exclude that configService.ts file from Github and generate it while building. To generate the file, we have 1 or 2 other files in place. The first file is a configService.ts.params file that will include the parameters and is available on Github. This file will be renamed to configService.ts before transpilation, resulting in javascript with our parameters included that can be replaced by the build server. Another optional file is configService.ts.dev, this file is for development only. If the file is found, it has precedence over the params file and will be the actual configService.ts file before transpilation. It's a copy of the params file but it contains actual values for the parameters. Of course, this file is also excluded from Github.

So just to remember:

  • for backend development... you need 1 web.debug.config that is a copy of web.release.config but with actual parameter values.
  • for frontend development... you need 1 configService.ts.dev file that is a copy of configService.ts.params but with actual parameter values.

Development

  • [Setup your environment](Run Locally)

Deployment

  • [Configure Authentication](Configure Authentication)
  • [Azure VSTS Deployment](Azure VSTS Deployment)

User Guide

Clone this wiki locally