Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
"ghcr.io/devcontainers/features/node:1": {
"version": "18"
},
"ghcr.io/devcontainers/features/docker-in-docker:1": {
"version": 20,
"moby": "false"
},
"ghcr.io/devcontainers/features/powershell:1": {},
"ghcr.io/devcontainers/features/azure-cli:1": {
"version": "latest",
Expand Down
68 changes: 68 additions & 0 deletions .github/workflows/azure-dev.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: Deploy on Azure
on:
workflow_dispatch:
push:
# Run when commits are pushed to mainline branch (main or master)
# Set this to the mainline branch you are using
branches:
- main
- master

# GitHub Actions workflow to deploy to Azure using azd
# To configure required secrets for connecting to Azure, simply run `azd pipeline config`

# Set up permissions for deploying with secretless Azure federated credentials
# https://learn.microsoft.com/en-us/azure/developer/github/connect-from-azure?tabs=azure-portal%2Clinux#set-up-azure-login-with-openid-connect-authentication
permissions:
id-token: write
contents: read

jobs:
build:
runs-on: ubuntu-latest
env:
AZURE_CLIENT_ID: ${{ vars.AZURE_CLIENT_ID }}
AZURE_TENANT_ID: ${{ vars.AZURE_TENANT_ID }}
AZURE_SUBSCRIPTION_ID: ${{ vars.AZURE_SUBSCRIPTION_ID }}
AZURE_CREDENTIALS: ${{ secrets.AZURE_CREDENTIALS }}
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Install azd
uses: Azure/setup-azd@v0.1.0

- name: Install Nodejs
uses: actions/setup-node@v3
with:
node-version: 18

- name: Log in with Azure (Federated Credentials)
if: ${{ env.AZURE_CLIENT_ID != '' }}
run: |
azd auth login `
--client-id "$Env:AZURE_CLIENT_ID" `
--federated-credential-provider "github" `
--tenant-id "$Env:AZURE_TENANT_ID"
shell: pwsh

- name: Log in with Azure (Client Credentials)
if: ${{ env.AZURE_CREDENTIALS != '' }}
run: |
$info = $Env:AZURE_CREDENTIALS | ConvertFrom-Json -AsHashtable;
Write-Host "::add-mask::$($info.clientSecret)"

azd auth login `
--client-id "$($info.clientId)" `
--client-secret "$($info.clientSecret)" `
--tenant-id "$($info.tenantId)"
shell: pwsh
env:
AZURE_CREDENTIALS: ${{ secrets.AZURE_CREDENTIALS }}

- name: Provision and deploy application
run: azd up --no-prompt
env:
AZURE_ENV_NAME: ${{ vars.AZURE_ENV_NAME }}
AZURE_LOCATION: ${{ vars.AZURE_LOCATION }}
AZURE_SUBSCRIPTION_ID: ${{ vars.AZURE_SUBSCRIPTION_ID }}
19 changes: 15 additions & 4 deletions infra/main.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,24 @@ param storageSkuName string
param openAiServiceName string = ''
param openAiResourceGroupName string = ''
@description('Location for the OpenAI resource group')
@allowed(['canadaeast', 'eastus', 'francecentral', 'japaneast', 'northcentralus'])
@allowed(['australiaeast', 'canadaeast', 'eastus', 'eastus2', 'francecentral', 'japaneast', 'northcentralus', 'swedencentral', 'switzerlandnorth', 'uksouth', 'westeurope'])
@metadata({
azd: {
type: 'location'
}
})
param openAiResourceGroupLocation string

param openAiSkuName string = 'S0'

@description('Location for the Static Web App')
@allowed(['westus2', 'centralus', 'eastus2', 'westeurope', 'eastasia', 'eastasiastage'])
@metadata({
azd: {
type: 'location'
}
})
param webAppLocation string

param formRecognizerServiceName string = ''
param formRecognizerResourceGroupName string = ''
param formRecognizerResourceGroupLocation string = location
Expand All @@ -68,9 +76,12 @@ param principalId string = ''
@description('Use Application Insights for monitoring and performance tracing')
param useApplicationInsights bool = false

// Only needed for CD due to internal policies restrictions
param aliasTag string = ''

var abbrs = loadJsonContent('abbreviations.json')
var resourceToken = toLower(uniqueString(subscription().id, environmentName, location))
var tags = { 'azd-env-name': environmentName }
var tags = union({ 'azd-env-name': environmentName }, empty(aliasTag) ? {} : { alias: aliasTag })

// Organize resources in a resource group
resource resourceGroup 'Microsoft.Resources/resourceGroups@2021-04-01' = {
Expand Down Expand Up @@ -127,7 +138,7 @@ module webApp './core/host/staticwebapp.bicep' = {
scope: resourceGroup
params: {
name: !empty(webAppName) ? webAppName : '${abbrs.webStaticSites}web-${resourceToken}'
location: location
location: webAppLocation
tags: union(tags, { 'azd-service-name': webAppName })
}
}
Expand Down
9 changes: 9 additions & 0 deletions infra/main.parameters.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,15 @@
"openAiResourceGroupName": {
"value": "${AZURE_OPENAI_RESOURCE_GROUP}"
},
"openAiResourceGroupLocation": {
"value": "${AZURE_OPENAI_RESOURCE_GROUP_LOCATION=eastus2}"
},
"openAiSkuName": {
"value": "S0"
},
"webAppLocation": {
"value": "${AZURE_WEBAPP_LOCATION=eastus2}"
},
"formRecognizerServiceName": {
"value": "${AZURE_FORMRECOGNIZER_SERVICE}"
},
Expand Down Expand Up @@ -61,6 +67,9 @@
},
"useApplicationInsights": {
"value": "${AZURE_USE_APPLICATION_INSIGHTS=false}"
},
"aliasTag": {
"value": "${AZURE_ALIAS}"
}
}
}