|
| 1 | +# Deployment Guide |
| 2 | + |
| 3 | +## **Pre-requisites** |
| 4 | + |
| 5 | +To deploy this solution accelerator, ensure you have access to an [Azure subscription](https://azure.microsoft.com/free/) with the necessary permissions to create **resource groups, resources, app registrations, and assign roles at the resource group level**. This should include Contributor role at the subscription level and Role Based Access Control role on the subscription and/or resource group level. Follow the steps in [Azure Account Set Up](./AzureAccountSetUp.md). |
| 6 | + |
| 7 | +Check the [Azure Products by Region](https://azure.microsoft.com/en-us/explore/global-infrastructure/products-by-region/?products=all®ions=all) page and select a **region** where the following services are available: |
| 8 | + |
| 9 | +- Azure OpenAI Service |
| 10 | +- Azure AI Search |
| 11 | +- [Azure Semantic Search](./AzureSemanticSearchRegion.md) |
| 12 | + |
| 13 | +Here are some example regions where the services are available: East US, East US2, Australia East, UK South, France Central. |
| 14 | + |
| 15 | +### **Important Note for PowerShell Users** |
| 16 | + |
| 17 | +If you encounter issues running PowerShell scripts due to the policy of not being digitally signed, you can temporarily adjust the `ExecutionPolicy` by running the following command in an elevated PowerShell session: |
| 18 | + |
| 19 | +```powershell |
| 20 | +Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass |
| 21 | +``` |
| 22 | + |
| 23 | +This will allow the scripts to run for the current session without permanently changing your system's policy. |
| 24 | + |
| 25 | +## Deployment Options & Steps |
| 26 | + |
| 27 | +Pick from the options below to see step-by-step instructions for GitHub Codespaces, VS Code Dev Containers, and Local Environments. |
| 28 | + |
| 29 | +| [](https://codespaces.new/microsoft/document-generation-solution-accelerator) | [](https://vscode.dev/redirect?url=vscode://ms-vscode-remote.remote-containers/cloneInVolume?url=https://github.com/microsoft/document-generation-solution-accelerator) | |
| 30 | +|---|---| |
| 31 | + |
| 32 | +<details> |
| 33 | + <summary><b>Deploy in GitHub Codespaces</b></summary> |
| 34 | + |
| 35 | +### GitHub Codespaces |
| 36 | + |
| 37 | +You can run this solution using GitHub Codespaces. The button will open a web-based VS Code instance in your browser: |
| 38 | + |
| 39 | +1. Open the solution accelerator (this may take several minutes): |
| 40 | + |
| 41 | + [](https://codespaces.new/microsoft/document-generation-solution-accelerator) |
| 42 | + |
| 43 | +2. Accept the default values on the create Codespaces page. |
| 44 | +3. Open a terminal window if it is not already open. |
| 45 | +4. Continue with the [deploying steps](#deploying-with-azd). |
| 46 | + |
| 47 | +</details> |
| 48 | + |
| 49 | +<details> |
| 50 | + <summary><b>Deploy in VS Code</b></summary> |
| 51 | + |
| 52 | +### VS Code Dev Containers |
| 53 | + |
| 54 | +You can run this solution in 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): |
| 55 | + |
| 56 | +1. Start Docker Desktop (install it if not already installed). |
| 57 | +2. Open the project: |
| 58 | + |
| 59 | + [](https://vscode.dev/redirect?url=vscode://ms-vscode-remote.remote-containers/cloneInVolume?url=https://github.com/microsoft/document-generation-solution-accelerator) |
| 60 | + |
| 61 | +3. In the VS Code window that opens, once the project files show up (this may take several minutes), open a terminal window. |
| 62 | +4. Continue with the [deploying steps](#deploying-with-azd). |
| 63 | + |
| 64 | +</details> |
| 65 | + |
| 66 | +<details> |
| 67 | + <summary><b>Deploy in your local Environment</b></summary> |
| 68 | + |
| 69 | +### Local Environment |
| 70 | + |
| 71 | +If you're not using one of the above options for opening the project, then you'll need to: |
| 72 | + |
| 73 | +1. Make sure the following tools are installed: |
| 74 | + - [PowerShell](https://learn.microsoft.com/en-us/powershell/scripting/install/installing-powershell?view=powershell-7.5) <small>(v7.0+)</small> - available for Windows, macOS, and Linux. (Required for Windows users only. Follow the steps [here](./PowershellSetup.md) to add it to the Windows PATH.) |
| 75 | + - [Azure Developer CLI (azd)](https://aka.ms/install-azd) |
| 76 | + - [Python 3.9+](https://www.python.org/downloads/) |
| 77 | + - [Docker Desktop](https://www.docker.com/products/docker-desktop/) |
| 78 | + - [Git](https://git-scm.com/downloads) |
| 79 | + |
| 80 | +2. Clone the repository or download the project code via command-line: |
| 81 | + |
| 82 | + ```shell |
| 83 | + azd init -t microsoft/document-generation-solution-accelerator/ |
| 84 | + ``` |
| 85 | + |
| 86 | +3. Open the project folder in your terminal or editor. |
| 87 | +4. Continue with the [deploying steps](#deploying-with-azd). |
| 88 | + |
| 89 | +</details> |
| 90 | + |
| 91 | +<br/> |
| 92 | + |
| 93 | +Consider the following settings during your deployment to modify specific settings: |
| 94 | + |
| 95 | +<details> |
| 96 | + <summary><b>Configurable Deployment Settings</b></summary> |
| 97 | + |
| 98 | +When you start the deployment, most parameters will have **default values**, but you can update the following settings: |
| 99 | + |
| 100 | +| **Setting** | **Description** | **Default value** | |
| 101 | +|------------|----------------| ------------| |
| 102 | +| **Azure Region** | The region where resources will be created. | eastus | |
| 103 | +| **Environment Name** | A **3-20 character alphanumeric value** used to generate a unique ID to prefix the resources. | byctemplate | |
| 104 | +| **Secondary Location** | A **less busy** region for **CosmosDB**, useful in case of availability constraints. | eastus2 | |
| 105 | +| **Deployment Type** | Select from a drop-down list. | Global Standard | |
| 106 | +| **GPT Model** | Choose from **gpt-4, gpt-4o** | gpt-4o | |
| 107 | +| **GPT Model Deployment Capacity** | Configure capacity for **GPT models**. | 30k | |
| 108 | +| **Embedding Model** | Default: **text-embedding-ada-002**. | text-embedding-ada-002 | |
| 109 | +| **Embedding Model Capacity** | Set the capacity for **embedding models**. | 80k | |
| 110 | + |
| 111 | +</details> |
| 112 | + |
| 113 | +<details> |
| 114 | + <summary><b>[Optional] Quota Recommendations</b></summary> |
| 115 | + |
| 116 | +By default, the _Gpt-4o model capacity_ in deployment is set to _30k tokens_, so we recommend: |
| 117 | +- **For Global Standard | GPT-4o** - the capacity to at least 150k tokens post-deployment for optimal performance. |
| 118 | + |
| 119 | +- **For Standard | GPT-4** - ensure a minimum of 30k–40k tokens for best results. |
| 120 | + |
| 121 | +To adjust quota settings, follow these [steps](./AzureGPTQuotaSettings.md). |
| 122 | + |
| 123 | +### ⚠️ Important: Check Azure OpenAI Quota Availability |
| 124 | + |
| 125 | +➡️ To ensure sufficient quota is available in your subscription, please follow **[Quota check instructions guide](./QuotaCheck.md)** before you deploy the solution. Insufficient quota can cause deployment errors. Please ensure you have the recommended capacity or request additional capacity before deploying this solution. |
| 126 | + |
| 127 | +</details> |
| 128 | + |
| 129 | +### Deploying with AZD |
| 130 | + |
| 131 | +Once you've opened the project in [Codespaces](#github-codespaces), [Dev Containers](#vs-code-dev-containers), or [locally](#local-environment), you can deploy it to Azure by following these steps: |
| 132 | +
|
| 133 | +1. Login to Azure: |
| 134 | +
|
| 135 | + ```shell |
| 136 | + azd auth login |
| 137 | + ``` |
| 138 | +
|
| 139 | + #### To authenticate with Azure Developer CLI (`azd`), use the following command with your **Tenant ID**: |
| 140 | +
|
| 141 | + ```sh |
| 142 | + azd auth login --tenant-id <tenant-id> |
| 143 | + ``` |
| 144 | +
|
| 145 | +2. Provision and deploy all the resources: |
| 146 | +
|
| 147 | + ```shell |
| 148 | + azd up |
| 149 | + ``` |
| 150 | +
|
| 151 | +3. Provide an `azd` environment name (e.g., "cpsapp"). |
| 152 | +4. Select a subscription from your Azure account and choose a location that has quota for all the resources. |
| 153 | + - This deployment will take *7-10 minutes* to provision the resources in your account and set up the solution with sample data. |
| 154 | + - If you encounter an error or timeout during deployment, changing the location may help, as there could be availability constraints for the resources. |
| 155 | +
|
| 156 | +5. Once the deployment has completed successfully and you would like to use the sample data, run the bash command printed in the terminal. The bash command will look like the following: |
| 157 | + ```shell |
| 158 | + bash ./infra/scripts/process_sample_data.sh <Storage-Account-name> <Storgae-Account-container-name> <Key-Vault-name> <CosmosDB-Account-name> <Resource-Group-name> |
| 159 | + ``` |
| 160 | +
|
| 161 | +6. Open the [Azure Portal](https://portal.azure.com/), go to the deployed resource group, find the App Service and get the app URL from `Default domain`. |
| 162 | +
|
| 163 | +7. You can now delete the resources by running `azd down`, if you are done trying out the application. |
| 164 | +
|
| 165 | +## Post Deployment Steps |
| 166 | +
|
| 167 | +1. **Add App Authentication** |
| 168 | +
|
| 169 | + > Note: Authentication changes can take up to 10 minutes |
| 170 | +
|
| 171 | + Follow steps in [App Authentication](./AppAuthentication.md) to configure authenitcation in app service. |
| 172 | +
|
| 173 | +2. **Deleting Resources After a Failed Deployment** |
| 174 | +
|
| 175 | + - Follow steps in [Delete Resource Group](./DeleteResourceGroup.md) if your deployment fails and/or you need to clean up the resources. |
| 176 | +
|
| 177 | +## Next Steps |
| 178 | +Now that you've completed your deployment, you can start using the solution. |
| 179 | + |
| 180 | +To help you get started, here are some [Sample Questions](./SampleQuestions.md) you can follow to try it out. |
0 commit comments