Skip to content

Commit

Permalink
Update README
Browse files Browse the repository at this point in the history
  • Loading branch information
justinyoo committed Oct 1, 2023
1 parent 228ba51 commit 8058828
Show file tree
Hide file tree
Showing 5 changed files with 189 additions and 47 deletions.
155 changes: 155 additions & 0 deletions .github/workflows/azure-dev.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
name: 'Azure Dev'

on:
workflow_dispatch:
push:
branches:
- main
- 'feature/*'
pull_request:
branches:
- main

permissions:
id-token: write
contents: read

env:
AZURE_RESOURCE_GROUP_NAME: 'rg-${{ vars.AZURE_ENV_NAME }}'
AZURE_FNCAPP_NAME: 'fncapp-${{ vars.AZURE_ENV_NAME }}'
AZURE_APIM_NAME: 'apim-${{ vars.AZURE_ENV_NAME }}'
# AZURE_STTAPP_NAME: 'sttapp-${{ vars.AZURE_ENV_NAME }}'
AZURE_OPENAI_NAME: 'aoai-${{ vars.AZURE_ENV_NAME }}'

jobs:
build-test:
name: Build Test

runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup .NET SDK
uses: actions/setup-dotnet@v3
with:
dotnet-version: 7.x

- name: Restore NuGet packages
shell: bash
run: |
dotnet restore
- name: Build solution
shell: bash
run: |
dotnet build -c Release
- name: Test solution
shell: bash
run: |
dotnet test -c Release
- name: Create artifacts
if: (github.event_name == 'push' && github.ref == 'refs/heads/main') || github.event_name == 'workflow_dispatch'
shell: bash
run: |
dotnet publish -c Release
- name: Upload artifact - API
if: (github.event_name == 'push' && github.ref == 'refs/heads/main') || github.event_name == 'workflow_dispatch'
uses: actions/upload-artifact@v3
with:
name: apiapp
path: src/YouTubeSummariser.ApiApp/bin/Release/net7.0/publish

deploy:
name: Deploy
if: (github.event_name == 'push' && github.ref == 'refs/heads/main') || github.event_name == 'workflow_dispatch'
needs:
- build-test

runs-on: ubuntu-latest

steps:
- name: Download artifact - API
uses: actions/download-artifact@v3
with:
name: apiapp
path: published/apiapp

- name: Login to Azure
uses: azure/login@v1
with:
client-id: ${{ vars.AZURE_CLIENT_ID }}
tenant-id: ${{ vars.AZURE_TENANT_ID }}
subscription-id: ${{ vars.AZURE_SUBSCRIPTION_ID }}

- name: Deploy Azure - API
uses: azure/webapps-deploy@v2
with:
app-name: '${{ env.AZURE_FNCAPP_NAME }}-aoai'
package: published/apiapp

# - name: Get SWA token
# shell: bash
# run: |
# swa_token=$(az staticwebapp secrets list \
# -g ${{ env.AZURE_RESOURCE_GROUP_NAME }} \
# -n ${{ env.AZURE_STTAPP_NAME }}-web \
# --query "properties.apiKey" -o tsv)

# echo "::add-mask::$swa_token"
# echo "SWA_TOKEN=$swa_token" >> $GITHUB_ENV

# - name: Deploy Azure - Web
# uses: Azure/static-web-apps-deploy@v1
# with:
# azure_static_web_apps_api_token: ${{ env.SWA_TOKEN }}
# action: "upload"
# app_location: 'src/YouTubeSummariser.WebApp.Wasm'
# api_location: ''
# # api_location: 'src/YouTubeSummariser.ApiApp'
# output_location: 'wwwroot'
# # app_build_command: 'dotnet publish -c Release -o bin'
# # api_build_command: 'dotnet publish -c Release'

- name: Update APIM settings
shell: bash
run: |
functionKey=$(az functionapp keys list \
--resource-group "${{ env.AZURE_RESOURCE_GROUP_NAME }}" \
--name "${{ env.AZURE_FNCAPP_NAME }}-aoai" \
--query "functionKeys.default" \
--output tsv)
nv=$(az apim nv update \
--resource-group ${{ env.AZURE_RESOURCE_GROUP_NAME }} \
--service-name ${{ env.AZURE_APIM_NAME }} \
--named-value-id "X_FUNCTIONS_KEY_AOAI" \
--value $functionKey \
--secret true)
- name: Update API settings - API
shell: bash
run: |
endpoint=$(az cognitiveservices account show \
--resource-group "${{ env.AZURE_RESOURCE_GROUP_NAME }}" \
--name "${{ env.AZURE_OPENAI_NAME }}" \
--query "properties.endpoint" -o tsv)
apikey=$(az cognitiveservices account keys list \
--resource-group "${{ env.AZURE_RESOURCE_GROUP_NAME }}" \
--name "${{ env.AZURE_OPENAI_NAME }}" \
--query "key1" -o tsv)
appsettings=$(az functionapp config appsettings set \
--resource-group "${{ env.AZURE_RESOURCE_GROUP_NAME }}" \
--name "${{ env.AZURE_FNCAPP_NAME }}-aoai" \
--settings "OpenAI__Endpoint=$endpoint")
appsettings=$(az functionapp config appsettings set \
--resource-group "${{ env.AZURE_RESOURCE_GROUP_NAME }}" \
--name "${{ env.AZURE_FNCAPP_NAME }}-aoai" \
--settings "OpenAI__ApiKey=$apikey")
41 changes: 0 additions & 41 deletions .github/workflows/main.yaml

This file was deleted.

31 changes: 27 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,31 @@ This provides sample Blazor apps that summarise a YouTube video transcript to a
- [Azure Subscription](https://azure.microsoft.com/free?WT.mc_id=dotnet-96932-juyoo)
- [Azure OpenAI Service](https://learn.microsoft.com/azure/ai-services/openai/overview?WT.mc_id=dotnet-96932-juyoo)

## Known Issues

- If your YouTube video is long enough, you might exceed the maximum number of tokens that Azure OpenAI Service can handle. For more information, see [Model summary](https://learn.microsoft.com/azure/ai-services/openai/concepts/models?WT.mc_id=dotnet-96932-juyoo#model-summary-table-and-region-availability).
- `gpt-35-turbo`: 4K
- `gpt-35-turbo-16k`: 16K
- `gpt-4`: 4K
- `gpt-4-32K`: 32K

## Getting Started

### Provision Azure OpenAI Service
### Provision Resources to Azure

1. Fork this repository to your GitHub account, `{{GITHUB_USERNAME}}`.
1. Run the commands below to set up a resource names:

```bash
# PowerShell
$AZURE_ENV_NAME="assistant$(Get-Random -Min 1000 -Max 9999)"
$AZURE_ENV_NAME="summariser$(Get-Random -Min 1000 -Max 9999)"
$GITHUB_USERNAME="{{GITHUB_USERNAME}}"
$GITHUB_REPOSITORY_NAME="{{GITHUB_REPOSITORY_NAME}}"

# Bash
AZURE_ENV_NAME="assistant$RANDOM"
AZURE_ENV_NAME="summariser$RANDOM"
GITHUB_USERNAME="{{GITHUB_USERNAME}}"
GITHUB_REPOSITORY_NAME="{{GITHUB_REPOSITORY_NAME}}"
```

1. Run the commands below to provision Azure resources:
Expand All @@ -34,6 +44,8 @@ This provides sample Blazor apps that summarise a YouTube video transcript to a
azd up
```

> **Note:** You may be asked to enter your GitHub username/orgname and repository name where your forked repository is located.

1. Get the endpoint, API key and deployment ID.

```bash
Expand Down Expand Up @@ -70,7 +82,18 @@ This provides sample Blazor apps that summarise a YouTube video transcript to a
--query "[0].name" -o tsv)
```
### Deprovision Azure OpenAI Service
### Deploy Applications to Azure
1. Run the commands below to deploy apps to Azure:
```bash
az login
gh auth login
azd pipeline config
gh workflow run "Azure Dev" --repo $GITHUB_USERNAME/$GITHUB_REPOSITORY_NAME
```
### Deprovision Resources from Azure
1. To avoid unexpected billing shock, run the commands below to deprovision Azure resources:
Expand Down
5 changes: 5 additions & 0 deletions infra/aoai-models.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,8 @@
version: '0613'
skuName: 'Standard'
skuCapacity: 16
# - name: 'gpt-4-32k'
# deploymentName: 'model-gpt432k'
# version: '0613'
# skuName: 'Standard'
# skuCapacity: 10
4 changes: 2 additions & 2 deletions infra/appsettings-aoai-openai.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
- name: 'OpenAIApi__Endpoint'
- name: 'OpenAI__Endpoint'
value: 'to_be_updated'
- name: 'OpenAI__ApiKey'
value: 'to_be_updated'
- name: 'OpenAIApi__DeploymentId'
- name: 'OpenAI__DeploymentId'
value: 'model-gpt35turbo16k'

0 comments on commit 8058828

Please sign in to comment.