|
| 1 | +# Manual Azure Deployment |
| 2 | +Manual Deployment differs from the ‘Quick Deploy’ option in that it will install an Azure Container Registry (ACR) service, and relies on the installer to build and push the necessary containers to this ACR. This allows you to build and push your own code changes and provides a sample solution you can customize based on your requirements. |
| 3 | + |
| 4 | +## Prerequisites |
| 5 | + |
| 6 | +- Current Azure CLI installed |
| 7 | + You can update to the latest version using ```az upgrade``` |
| 8 | +- Azure account with appropriate permissions |
| 9 | +- Docker installed |
| 10 | + |
| 11 | +## Deploy the Azure Services |
| 12 | +All of the necessary Azure services can be deployed using the /deploy/macae.bicep script. This script will require the following parameters: |
| 13 | + |
| 14 | +``` |
| 15 | +az login |
| 16 | +az account set --subscription <SUBSCRIPTION_ID> |
| 17 | +az group create --name <RG_NAME> --location <RG_LOCATION> |
| 18 | +``` |
| 19 | +To deploy the script you can use the Azure CLI. |
| 20 | +``` |
| 21 | +az deployment group create \ |
| 22 | + --resource-group <RG_NAME> \ |
| 23 | + --template-file <BICEP_FILE> \ |
| 24 | + --name <DEPLOYMENT_NAME> |
| 25 | +``` |
| 26 | + |
| 27 | +Note: if you are using windows with PowerShell, the continuation character (currently ‘\’) should change to the tick mark (‘`’). |
| 28 | + |
| 29 | +The template will require you fill in locations for Cosmos and OpenAI services. This is to avoid the possibility of regional quota errors for either of these resources. |
| 30 | + |
| 31 | +## Create the Containers |
| 32 | +- Get admin credentials from ACR |
| 33 | + |
| 34 | +Retrieve the admin credentials for your Azure Container Registry (ACR): |
| 35 | + |
| 36 | +```sh |
| 37 | +az acr credential show \ |
| 38 | +--name <e.g. macaeacr2t62qyozi76bs> \ |
| 39 | +--resource-group <rg-name> |
| 40 | +``` |
| 41 | + |
| 42 | +## Login to ACR |
| 43 | + |
| 44 | +Login to your Azure Container Registry: |
| 45 | + |
| 46 | +```sh |
| 47 | +az acr login --name <e.g. macaeacr2t62qyozi76bs> |
| 48 | +``` |
| 49 | + |
| 50 | +## Build and push the image |
| 51 | + |
| 52 | +Build the frontend and backend Docker images and push them to your Azure Container Registry. Run the following from the src/backend and the src/frontend directory contexts: |
| 53 | + |
| 54 | +```sh |
| 55 | +az acr build \ |
| 56 | +--registry <e.g. macaeacr2t62qyozi76bs> \ |
| 57 | +--resource-group <rg-name> \ |
| 58 | +--image <e.g. backendmacae:latest> . |
| 59 | +``` |
| 60 | + |
| 61 | +## Add images to the Container APP and Web App services |
| 62 | + |
| 63 | +To add your newly created backend image: |
| 64 | +- Navigate to the Container App Service in the Azure portal |
| 65 | +- Click on Application/Containers in the left pane |
| 66 | +- Click on the "Edit and deploy" button in the upper left of the containers pane |
| 67 | +- In the "Create and deploy new revision" page, click on your container image 'backend'. This will give you the option of reconfiguring the container image, and also has an Environment variables tab |
| 68 | +- Change the properties page to |
| 69 | + - point to your Azure Container registry with a private image type and your image name (e.g. backendmacae:latest) |
| 70 | + - under "Authentication type" select "Managed Identity" and choose the 'mace-containerapp-pull'... identity setup in the bicep template |
| 71 | +- In the environment variables section add the following (each with a 'Manual entry' source): |
| 72 | + |
| 73 | + name: 'COSMOSDB_ENDPOINT' |
| 74 | + value: \<Cosmos endpoint> |
| 75 | + |
| 76 | + name: 'COSMOSDB_DATABASE' |
| 77 | + value: 'autogen' |
| 78 | + Note: To change the default, you will need to create the database in Cosmos |
| 79 | + |
| 80 | + name: 'COSMOSDB_CONTAINER' |
| 81 | + value: 'memory' |
| 82 | + |
| 83 | + name: 'AZURE_OPENAI_ENDPOINT' |
| 84 | + value: <Azure OpenAI endpoint> |
| 85 | + |
| 86 | + name: 'AZURE_OPENAI_DEPLOYMENT_NAME' |
| 87 | + value: 'gpt-4o' |
| 88 | + |
| 89 | + name: 'AZURE_OPENAI_API_VERSION' |
| 90 | + value: '2024-08-01-preview' |
| 91 | + Note: Version should be updated based on latest available |
| 92 | + |
| 93 | + name: 'FRONTEND_SITE_NAME' |
| 94 | + value: 'https://<website Name>.azurewebsites.net' |
| 95 | + |
| 96 | + name: 'APPLICATIONINSIGHTS_CONNECTION_STRING' |
| 97 | + value: <Application Insights Connection String> |
| 98 | + |
| 99 | +- Click 'Save' and deploy your new revision |
| 100 | + |
| 101 | +To add the new container to your website run the following: |
| 102 | + |
| 103 | +``` |
| 104 | +az webapp config container set --resource-group <resource_group_name> \ |
| 105 | +--name <container_name> \ |
| 106 | +--container-image-name <e.g. macaeacr2t62qyozi76bs.azurecr.io/frontendmacae:latest> \ |
| 107 | +--container-registry-url <e.g. https://macaeacr2t62qyozi76bs.azurecr.io> |
| 108 | +``` |
| 109 | + |
0 commit comments