Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,23 @@ The web server and SQL database are the minimum requirements for this app to wor

You can use this link to deploy all resources automatically in your Azure subscription [![Deploy to Azure](https://aka.ms/deploytoazurebutton)](https://portal.azure.com/#create/Microsoft.Template/uri/https%3A%2F%2Fraw.githubusercontent.com%2Fmageroni%2Fcopilot-survey-engine%2Fmain%2Fdeployment%2Ftemplate.json)

Configure the app's SQL credentials separately from the SQL server administrator credentials for either deployment template. Before starting the app, connect as the SQL server administrator to the `copilotUsage` database and create a contained database user named `copilotSurveyApp`.

Both templates disable public network access on the SQL server. Run the SQL below from a host that can resolve and reach its private endpoint, or temporarily enable public access with a firewall rule for your client IP, run the script, and then disable public access again.

For `deployment/template.bicep`, use the password supplied as `sqlApplicationLoginPassword`; for the Deploy to Azure button (`deployment/template.json`), choose a separate application password. When setting `DATABASE_CONNECTION_STRING` manually, use `User ID=copilotSurveyApp` and that application password instead of the administrator credentials. Grant that user only the permissions needed by the app:

```sql
CREATE USER [copilotSurveyApp] WITH PASSWORD = '<application-password>';
GRANT CREATE TABLE TO [copilotSurveyApp];
GRANT ALTER ON SCHEMA::dbo TO [copilotSurveyApp];
GRANT SELECT, INSERT, UPDATE ON SCHEMA::dbo TO [copilotSurveyApp];
```

The app creates `SurveyResults` on first use and then reads and writes survey responses. After the table has been created successfully, connect as the SQL server administrator to `copilotUsage` and run `REVOKE CREATE TABLE FROM [copilotSurveyApp];` and `REVOKE ALTER ON SCHEMA::dbo FROM [copilotSurveyApp];` to remove the bootstrap permissions.

The existing `SELECT`, `INSERT`, and `UPDATE` grants are sufficient for subsequent survey responses. Do not use the SQL server administrator credentials for the app connection.

### Step 2. Execute locally and configure secrets

To run the application on you local machine you'll need to have installed NodeJS. Once you have it, you can access to the folder where you've cloned this project and run the following:
Expand Down
6 changes: 5 additions & 1 deletion deployment/template.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ param sqlAdministratorLogin string
@secure()
param sqlAdministratorLoginPassword string

@description('Password for the application-specific Azure SQL database user')
@secure()
param sqlApplicationLoginPassword string

@description('application insights name')
param appInsightsName string

Expand Down Expand Up @@ -310,7 +314,7 @@ resource appService 'Microsoft.Web/sites@2022-09-01' = {
}
{
name: 'DATABASE_CONNECTION_STRING'
value: 'Server=tcp:${sqlServer.name}${environment().suffixes.sqlServerHostname},1433;Initial Catalog=copilotUsage;Persist Security Info=False;User ID=${sqlAdministratorLogin};Password=${sqlAdministratorLoginPassword};MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;'
value: 'Server=tcp:${sqlServer.name}${environment().suffixes.sqlServerHostname},1433;Initial Catalog=copilotUsage;Persist Security Info=False;User ID=copilotSurveyApp;Password=${sqlApplicationLoginPassword};MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;'
}
{
name: 'LANGUAGE_API_ENDPOINT'
Expand Down
Loading