Skip to content

Commit

Permalink
Brought back One Click deploy (Azure-Samples#538)
Browse files Browse the repository at this point in the history
* Brought back One Click deploy

* PR comments

* Update readme

* Default useKeyVault to false if using rbac
  • Loading branch information
ross-p-smith authored Mar 27, 2024
1 parent 8a94caf commit 6cbb282
Show file tree
Hide file tree
Showing 6 changed files with 72 additions and 73 deletions.
43 changes: 11 additions & 32 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,55 +129,34 @@ The following are links to the pricing details for some of the resources:

### Deploy instructions

There are two choices; the "Deploy to Azure" offers a one click deployment where you don't have to clone the code, alternatively if you would like a developer experience, follow the [Local deployment instructions](./docs/LOCAL_DEPLOYMENT.md).

The demo, which uses containers pre-built from the main branch is available by clicking this button:

[![Deploy to Azure](https://aka.ms/deploytoazurebutton)](https://portal.azure.com/#create/Microsoft.Template/uri/https%3A%2F%2Fraw.githubusercontent.com%2FAzure-Samples%2Fchat-with-your-data-solution-accelerator%2Fmain%2Finfra%2Fmain.json)

**Note**: The default configuration deploys an OpenAI Model "gpt-35-turbo" with version 0613. However, not all
locations support this version. If you're deploying to a location that doesn't support version 0613, you'll need to
switch to a lower version. To find out which versions are supported in different regions, visit the
[GPT-35 Turbo Model Availability](https://learn.microsoft.com/en-us/azure/ai-services/openai/concepts/models#gpt-35-turbo-model-availability) page.

The easiest way to run this accelerator is in a VS Code Dev Containers, which will open the project in your local VS Code using the [Dev Containers extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers):

1. Start Docker Desktop (install it if not already installed)
1. Open the project:
[![Open in Dev Containers](https://img.shields.io/static/v1?style=for-the-badge&label=Dev%20Containers&message=Open&color=blue&logo=visualstudiocode)](https://vscode.dev/redirect?url=vscode://ms-vscode-remote.remote-containers/cloneInVolume?url=https://github.com/azure-samples/chat-with-your-data-solution-accelerator)
1. In the VS Code window that opens, once the project files show up (this may take several minutes), open a terminal window
1. Run `azd auth login`
1. Run `azd env set AZURE_APP_SERVICE_HOSTING_MODEL code` - This sets your environment to depoloy code rather than rely on public containers.
1. Run `azd up` - This will provision Azure resources and deploy the accelerator to those resources.

* **Important**: Beware that the resources created by this command will incur immediate costs, primarily from the AI Search resource. These resources may accrue costs even if you interrupt the command before it is fully executed. You can run `azd down` or delete the resources manually to avoid unnecessary spending.
* You will be prompted to select a subscription, and a location. That location list is based on the [OpenAI model availability table](https://learn.microsoft.com/azure/cognitive-services/openai/concepts/models#model-summary-table-and-region-availability) and may become outdated as availability changes.
* If you do, accidentally, chose the wrong location; you will have to ensure that you use `azd down` or delete the Resource Group as the deployment bases the location from this Resource Group.
1. After the application has been successfully deployed you will see a URL printed to the console. Click that URL to interact with the application in your browser.

> NOTE: It may take 30 minutes for the application to be fully deployed. If you see a "Python Developer" welcome screen or an error page, then wait a bit and refresh the page.
**Notes:** the default auth type uses keys, if you want to switch to rbac, please run `azd env set AUTH_TYPE rbac`.


#### Testing the deployment
### Testing the deployment
1. Navigate to the admin site, where you can upload documents. It will be located at:

`https://{MY_RESOURCE_PREFIX}-website-admin.azurewebsites.net/`
`https://web-{RESOURCE_TOKEN}-admin.azurewebsites.net/`

Where `{MY_RESOURCE_PREFIX}` is replaced with the resource prefix you used during deployment. Then select **Ingest Data** and add your data. You can find sample data in the `/data` directory.
Where `{RESOURCE_TOKEN}` is uniquely generated during deployment. This is a combination of your subscription and the name of the resource group. Then select **Ingest Data** and add your data. You can find sample data in the `/data` directory.

![A screenshot of the admin site.](./media/admin-site.png)


2. Navigate to the web app to start chatting on top of your data. The web app can be found at:

`https://{MY_RESOURCE_PREFIX}-website.azurewebsites.net/`

Where `{MY_RESOURCE_PREFIX}` is replaced with the resource prefix you used during deployment.
`https://web-{RESOURCE_TOKEN}.azurewebsites.net/`


![A screenshot of the chat app.](./media/web-unstructureddata.png)


You can also run the sample directly locally (See below).

### [Local deployment instructions](./docs/LOCAL_DEPLOYMENT.md)
To customize the accelerator or run it locally, first, copy the .env.sample file to your development environment's .env file, and edit it according to environment variable values table. Learn more about deploying locally [here](./docs/LOCAL_DEPLOYMENT.md).
\
\
![Supporting documentation](/media/supportingDocuments.png)
Expand Down
26 changes: 0 additions & 26 deletions docs/INFRA_DEPLOYMENT.md

This file was deleted.

37 changes: 34 additions & 3 deletions docs/LOCAL_DEPLOYMENT.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,27 @@
[Back to *Chat with your data* README](../README.md)

## Development Container
# Local setup

The easiest way to run this accelerator is in a VS Code Dev Containers, which will open the project in your local VS Code using the [Dev Containers extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers):

1. Start Docker Desktop (install it if not already installed)
1. Open the project:
[![Open in Dev Containers](https://img.shields.io/static/v1?style=for-the-badge&label=Dev%20Containers&message=Open&color=blue&logo=visualstudiocode)](https://vscode.dev/redirect?url=vscode://ms-vscode-remote.remote-containers/cloneInVolume?url=https://github.com/azure-samples/chat-with-your-data-solution-accelerator)
1. In the VS Code window that opens, once the project files show up (this may take several minutes), open a terminal window
1. Run `azd auth login`
1. Run `azd env set AZURE_APP_SERVICE_HOSTING_MODEL code` - This sets your environment to deploy code rather than rely on public containers, like the "Deploy to Azure" button.
1. Run `azd up` - This will provision Azure resources and deploy the accelerator to those resources.

* **Important**: Beware that the resources created by this command will incur immediate costs, primarily from the AI Search resource. These resources may accrue costs even if you interrupt the command before it is fully executed. You can run `azd down` or delete the resources manually to avoid unnecessary spending.
* You will be prompted to select a subscription, and a location. That location list is based on the [OpenAI model availability table](https://learn.microsoft.com/azure/cognitive-services/openai/concepts/models#model-summary-table-and-region-availability) and may become outdated as availability changes.
* If you do, accidentally, chose the wrong location; you will have to ensure that you use `azd down` or delete the Resource Group as the deployment bases the location from this Resource Group.
1. After the application has been successfully deployed you will see a URL printed to the console. Click that URL to interact with the application in your browser.

> NOTE: It may take up to an hour for the application to be fully deployed. If you see a "Python Developer" welcome screen or an error page, then wait a bit and refresh the page.
**Notes:** the default auth type uses keys, if you want to switch to rbac, please run `azd env set AUTH_TYPE rbac`.

## Detailed Development Container setup instructions

The solution contains a [development container](https://code.visualstudio.com/docs/remote/containers) with all the required tooling to develop and deploy the accelerator. To deploy the Chat With Your Data accelerator using the provided development container you will also need:

Expand All @@ -26,7 +47,7 @@ When you start the development container for the first time, the container will

The files for the dev container are located in `/.devcontainer/` folder.

## Local deployment
## Local debugging

To customize the accelerator or run it locally, you must provision the Azure resources by running `azd provision` in a Terminal. This will generate a `.env` for you and you can use the "Run and Debug" (Ctrl + Shift + D) command to chose which part of the accelerator to run. There is an [environment variable values table](#environment-variables) below.

Expand Down Expand Up @@ -169,4 +190,14 @@ Execute the above [shell command](#L81) to run the function locally. You may nee
|AZURE_CONTENT_SAFETY_KEY | | The key of the Azure AI Content Safety service|
|AZURE_SPEECH_SERVICE_KEY | | The key of the Azure Speech service|
|AZURE_SPEECH_SERVICE_REGION | | The region (location) of the Azure Speech service|
|AZURE_AUTH_TYPE | keys | The default is to use API keys. Change the value to 'rbac' to authenticate using Role Based Access Control. For more information refer to section [Authenticate using RBAC](#authenticate-using-rbac)
|AZURE_AUTH_TYPE | keys | The default is to use API keys. Change the value to 'rbac' to authenticate using Role Based Access Control. For more information refer to section [Authenticate using RBAC](#authenticate-using-rbac)

## Bicep

A [Bicep file](./infra/main.bicep) is used to generate the [ARM template](./infra/main.json). You can deploy this accelerator by the following command

```sh
RESOURCE_GROUP_NAME=cwyd
az group create --location uksouth --resource-group $RESOURCE_GROUP_NAME
az deployment group create --resource-group $RESOURCE_GROUP_NAME --template-file ./infra/main.bicep
```
14 changes: 9 additions & 5 deletions infra/main.bicep
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
targetScope = 'subscription'

@minLength(1)
@maxLength(64)
@maxLength(20)
@description('Name of the the environment which is used to generate a short unique hash used in all resources.')
param environmentName string

Expand Down Expand Up @@ -82,7 +82,7 @@ param azureOpenAIModelVersion string = '0613'
'openai_function'
'langchain'
])
param orchestrationStrategy string = 'langchain'
param orchestrationStrategy string = 'openai_function'

@description('Azure OpenAI Temperature')
param azureOpenAITemperature string = '0'
Expand Down Expand Up @@ -147,22 +147,26 @@ param speechServiceName string = 'speech-${resourceToken}'

param newGuidString string = newGuid()
param searchTag string = 'chatwithyourdata-sa'
param useKeyVault bool

@description('Whether to use Key Vault to store secrets (best when using keys). If using RBAC, then please set this to false.')
param useKeyVault bool = authType == 'rbac' ? false : true

@description('Id of the user or app to assign application roles')
param principalId string = ''

@description('Whether the Azure services communicate with each other using RBAC or keys. RBAC is recommended, however some users may not have sufficient permissions to assign roles.')
@allowed([
'rbac'
'keys'
])
param authType string
param authType string = 'keys'

@description('Hosting model for the web apps. Containers are prebuilt and can be deployed faster, but code allows for more customization.')
@allowed([
'code'
'container'
])
param hostingModel string
param hostingModel string = 'container'

var blobContainerName = 'documents'
var queueName = 'doc-processing'
Expand Down
1 change: 0 additions & 1 deletion infra/main.bicepparam
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,3 @@ param azureAISearchName = searchServiceName == '' ? 'search-${resourceToken}' :

param azureSearchIndex = readEnvironmentVariable('AZURE_SEARCH_INDEX', 'index-${resourceToken}')
param azureOpenAIResourceName = readEnvironmentVariable('AZURE_OPENAI_RESOURCE', 'openai-${resourceToken}')

24 changes: 18 additions & 6 deletions infra/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
"_generator": {
"name": "bicep",
"version": "0.26.54.24096",
"templateHash": "15896839495287086142"
"templateHash": "14128916852168327812"
}
},
"parameters": {
"environmentName": {
"type": "string",
"minLength": 1,
"maxLength": 64,
"maxLength": 20,
"metadata": {
"description": "Name of the the environment which is used to generate a short unique hash used in all resources."
}
Expand Down Expand Up @@ -166,7 +166,7 @@
},
"orchestrationStrategy": {
"type": "string",
"defaultValue": "langchain",
"defaultValue": "openai_function",
"allowedValues": [
"openai_function",
"langchain"
Expand Down Expand Up @@ -317,7 +317,11 @@
"defaultValue": "chatwithyourdata-sa"
},
"useKeyVault": {
"type": "bool"
"type": "bool",
"defaultValue": "[if(equals(parameters('authType'), 'rbac'), false(), true())]",
"metadata": {
"description": "Whether to use Key Vault to store secrets (best when using keys). If using RBAC, then please set this to false."
}
},
"principalId": {
"type": "string",
Expand All @@ -328,17 +332,25 @@
},
"authType": {
"type": "string",
"defaultValue": "keys",
"allowedValues": [
"rbac",
"keys"
]
],
"metadata": {
"description": "Whether the Azure services communicate with each other using RBAC or keys. RBAC is recommended, however some users may not have sufficient permissions to assign roles."
}
},
"hostingModel": {
"type": "string",
"defaultValue": "container",
"allowedValues": [
"code",
"container"
]
],
"metadata": {
"description": "Hosting model for the web apps. Containers are prebuilt and can be deployed faster, but code allows for more customization."
}
}
},
"variables": {
Expand Down

0 comments on commit 6cbb282

Please sign in to comment.