Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Expand

General instructions for setting App settings and connection strings

  • Open the App Service that you want to set values for
  • On the left menu find the "Configuration" option
  • There will be an option towards the top of the screen to create new AppSettings and one at the bottom to bulk-edit connection strings
  • After adding or changing values make sure to save the app service.

WebApi application settings

  • The webApi should have an Application Setting of “AppSettings:Mode” and a Value of “YearSpecific”

Admin App application settings

  • The Admin App should have an Application Setting of “AppSettings:ProductionApiUrl” and a Value of the URL for for the Web API

Swagger application settings

  • Swagger App should have an Application Setting of ““WebApiVersionUrl”” and a Value of the URL for for the Web API

NOTE: Make sure when you finish adding the settings you save the changes

Configure Database Connection

There are two methods of database configuring database connection strings we are describing. The first one has the database credentials hardcoded in the settings for that App Service. This is a violation of some organization's security policy. The second method uses the key vault set up in step 4 to hold the credentials.

Deck
idConfigure database connection


Card
labelCredentials hard coded in the connection string

In this section, we will configure AdminApp and WebApi connection strings directly.

WebApi

  • From the azure portal home page, search for App Services
  • Select the WebApi App Service
  • Go to select Settings => Configuration
  • Under the Connection string section, select Advance Edit
  • Paste the following code into the text area that is prompted, replacing the Server, User Id, and Passwords with the details for the Azure Sql Server.
Code Block
languagejs
[
  {
    "name": "EdFi_Admin",
    "value": "Server=<Your SQL server name here>; Database=EdFi_Admin; User Id=<Your SQL username here>; Password= <your SQL Password here>; Application Name=EdFi.Ods.WebApi;",
    "type": "SQLAzure",
    "slotSetting": false
  },
  {
    "name": "EdFi_Ods",
    "value": "Server=<Your SQL server name here>; Database=EdFi_{0}; User Id=<Your SQL username here>; Password= <your SQL Password here>; Application Name=EdFi.Ods.WebApi;",
    "type": "SQLAzure",
    "slotSetting": false
  },
  {
    "name": "EdFi_Security",
    "value": "Server=<Your SQL server name here>; Database=EdFi_Security; User Id=<Your SQL username here>; Password= <your SQL Password here>; Application Name=EdFi.Ods.WebApi;",
    "type": "SQLAzure",
    "slotSetting": false
  }
]


Admin App

  • From the azure portal home page, search for App Services
  • Select the Admin App app Service
  • Go to select Settings => Configuration
  • Under the Connection string section, select Advance Edit
  • Paste the following code into the text area that is prompted, replacing the Server, User Id, and Passwords with the details for the Azure Sql Server.
Code Block
languagejs
[
  {
    "name": "Admin",
    "value": "Server=<Your SQL server name here>; Database=EdFi_Admin; User Id=<Your SQL username here>; Password= <your SQL Password here>; Application Name=EdFi.Ods.WebApi;",
    "type": "SQLAzure",
    "slotSetting": false
  },
  {
    "name": "ProductionOds",
    "value": "Server=<Your SQL server name here>; Database=EdFi_{0}; User Id=<Your SQL username here>; Password= <your SQL Password here>; Application Name=EdFi.Ods.WebApi;",
    "type": "SQLAzure",
    "slotSetting": false
  },
  {
    "name": "Security",
    "value": "Server=<Your SQL server name here>; Database=EdFi_Security; User Id=<Your SQL username here>; Password= <your SQL Password here>; Application Name=EdFi.Ods.WebApi;",
    "type": "SQLAzure",
    "slotSetting": false
  }
]



Card
labelUsing Key vault

In this section, we will configure AdminApp and WebApi to pull the database connection string from the key vault

Prerequisite: you must have followed the instruction in step 4 on how to set up the azure key vault

  • From the azure portal home page, search for App Services
  • Select the App service on which you have the WebApi configured
  • Inside WebApi Service, select Settings => Configuration
  • Under the Connection string section, select Advance Edit
  • Paste the following code into the text area that is prompted
Code Block
languagejs
[
 {
   "name": "EdFi_Admin",
   "value": "@Microsoft.KeyVault(SecretUri={Secret Identifier})",
   "type": "SQLAzure",
   "slotSetting": false
 },
 {
   "name": "EdFi_Ods",
   "value": "@Microsoft.KeyVault(SecretUri={Secret Identifier})",
   "type": "SQLAzure",
   "slotSetting": false
 },
 {
   "name": "EdFi_Security",
   "value": "@Microsoft.KeyVault(SecretUri={Secret Identifier})",
   "type": "SQLAzure",
   "slotSetting": false
 }
]

Configure the following properties inside the above JSON

  • value: "{Secret Identifier}"  must be replaced with the secret identifier value that is auto-generated from the secret (Step 4.2)

  • name: must match the name of the database that you have in your appsettings.json 

Once done, you will end up with something similar to this 


  • Once done and verified that everything is correct, save the changes

Important: Repeat all the above steps for AdminApp

Configure Azure App Insights

In this section, we will add logging support through Azure App Insights for WebApi

  • From the azure portal home page, search for App Services
  • Select the App service on which you have the WebApi configured
  • Inside WebApi Service, select Settings => Configuration
  • Select New application setting
  • Enter the following information
    • Name: should match the name that you have in the appsettings.json (ApplicationInsights:InstrumentationKey)

    • Value: should be the Instrumentation key that is provided on your App Insight

  • Once done, save the changes


To Configured Custom Messages on App Insights

  • Search for log4net.config file in your files published to your app service
  • edit the appender tag with name AppInsightsAppender 

  • use the conversionPattern to add any custom message
  • make sure to save the changes