semantic-kernel

Deploying Copilot Chat

This document details how to deploy CopilotChat’s required resources to your Azure subscription.

Things to know

Configure your environment

Before you get started, make sure you have the following requirements in place:

Deploy Azure Infrastructure

The examples below assume you are using an existing Azure OpenAI resource. See the notes following each command for using OpenAI or creating a new Azure OpenAI resource.

PowerShell

./deploy-azure.ps1 -Subscription {YOUR_SUBSCRIPTION_ID} -DeploymentName {YOUR_DEPLOYMENT_NAME} -AIService {AzureOpenAI or OpenAI} -AIApiKey {YOUR_AI_KEY} -AIEndpoint {YOUR_AZURE_OPENAI_ENDPOINT}

Bash

chmod +x ./deploy-azure.sh
./deploy-azure.sh --subscription {YOUR_SUBSCRIPTION_ID} --deployment-name {YOUR_DEPLOYMENT_NAME} --ai-service {AzureOpenAI or OpenAI} --ai-service-key {YOUR_AI_KEY} --ai-endpoint {YOUR_AZURE_OPENAI_ENDPOINT}

Azure Portal

You can also deploy the infrastructure directly from the Azure Portal by clicking the button below:

Deploy to Azure

This will automatically deploy the most recent release of CopilotChat backend binaries (link).

To find the deployment name when using Deploy to Azure, look for a deployment in your resource group that starts with Microsoft.Template.

Deploy Backend (WebAPI)

To deploy the backend, build the deployment package first and deploy it to the Azure resources created above.

PowerShell

./package-webapi.ps1 

./deploy-webapi.ps1 -Subscription {YOUR_SUBSCRIPTION_ID} -ResourceGroupName rg-{YOUR_DEPLOYMENT_NAME} -DeploymentName {YOUR_DEPLOYMENT_NAME}

Bash

chmod +x ./package-webapi.sh
./package-webapi.sh

chmod +x ./deploy-webapi.sh
./deploy-webapi.sh --subscription {YOUR_SUBSCRIPTION_ID} --resource-group rg-{YOUR_DEPLOYMENT_NAME} --deployment-name {YOUR_DEPLOYMENT_NAME}

Deploy Frontend (WebApp)

Prerequisites

App registration (identity)

You will need an Azure Active Directory (AAD) application registration.

For details on creating an application registration, go here.

Install Azure’s Static Web Apps CLI

npm install -g @azure/static-web-apps-cli

PowerShell


./deploy-webapp.ps1 -Subscription {YOUR_SUBSCRIPTION_ID} -ResourceGroupName rg-{YOUR_DEPLOYMENT_NAME} -DeploymentName {YOUR_DEPLOYMENT_NAME} -ApplicationClientId {YOUR_APPLICATION_ID}

Bash

./deploy-webapp.sh --subscription {YOUR_SUBSCRIPTION_ID} --resource-group rg-{YOUR_DEPLOYMENT_NAME} --deployment-name {YOUR_DEPLOYMENT_NAME} --application-id {YOUR_APPLICATION_ID}

Your CopilotChat application is now deployed!

Appendix

Using custom web frontends to access your deployment

Make sure to include your frontend’s URL as an allowed origin in your deployment’s CORS settings. Otherwise, web browsers will refuse to let JavaScript make calls to your deployment.

To do this, go on the Azure portal, select your Semantic Kernel App Service, then click on “CORS” under the “API” section of the resource menu on the left of the page. This will get you to the CORS page where you can add your allowed hosts.

Authorization

All of endpoints (except /healthz) require authorization to access. By default, an API key is required for access which can be found in the Authorization:ApiKey configuration setting. To authorize requests with the API key, add the API key value to a x-sk-api-key header in your requests.

To view your CopilotChat API key:

PowerShell

$webApiName = $(az deployment group show --name {DEPLOYMENT_NAME} --resource-group rg-{DEPLOYMENT_NAME} --output json | ConvertFrom-Json).properties.outputs.webapiName.value

($(az webapp config appsettings list --name $webapiName --resource-group rg-{YOUR_DEPLOYMENT_NAME} | ConvertFrom-JSON) | Where-Object -Property name -EQ -Value Authorization:ApiKey).value

Bash

eval WEB_API_NAME=$(az deployment group show --name $DEPLOYMENT_NAME --resource-group $RESOURCE_GROUP --output json) | jq -r '.properties.outputs.webapiName.value'

$(az webapp config appsettings list --name $WEB_API_NAME --resource-group rg-{YOUR_DEPLOYMENT_NAME} | jq '.[] | select(.name=="Authorization:ApiKey").value')