Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update scripts for infra #28

Merged
merged 4 commits into from
Jul 10, 2024
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
50 changes: 50 additions & 0 deletions .github/workflows/azure-dev-build-only.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Azure Dev - Build Only

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

jobs:
build-test:

runs-on: ubuntu-latest

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

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

- name: Install local certs
shell: pwsh
run: |
dotnet dev-certs https --clean
dotnet dev-certs https --trust

- name: Install Aspire workload
shell: pwsh
run: |
dotnet workload update
dotnet workload install aspire

- name: Restore NuGet packages
shell: bash
run: |
dotnet restore

- name: Build solution
shell: bash
run: |
dotnet build

- name: Test solution
shell: bash
run: |
dotnet test
123 changes: 35 additions & 88 deletions .github/workflows/azure-dev.yml
Original file line number Diff line number Diff line change
@@ -1,108 +1,42 @@
name: Azure Dev

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

# 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:
build-test-deploy:

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_ENV_NAME: ${{ vars.AZURE_ENV_NAME }}
AZURE_LOCATION: ${{ vars.AZURE_LOCATION }}

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

# - name: Login to Azure
# if: github.ref == 'refs/heads/main' || github.event_name == 'workflow_dispatch'
# uses: azure/login@v1
# with:
# tenant-id: ${{ vars.AZURE_TENANT_ID }}
# subscription-id: ${{ vars.AZURE_SUBSCRIPTION_ID }}
# client-id: ${{ vars.AZURE_CLIENT_ID }}

# # - name: Install Azure Developer CLI
# # if: github.ref == 'refs/heads/main' || github.event_name == 'workflow_dispatch'
# # uses: Azure/[email protected]

# - name: Install Azure Developer CLI (nightly build)
# if: github.ref == 'refs/heads/main' || github.event_name == 'workflow_dispatch'
# shell: pwsh
# run: |
# Invoke-RestMethod 'https://aka.ms/install-azd.ps1' -OutFile ./install-azd.ps1
# ./install-azd.ps1 -Version daily

# - name: Login to Azure Developer CLI
# if: github.ref == 'refs/heads/main' || github.event_name == 'workflow_dispatch'
# shell: pwsh
# run: |
# azd auth login `
# --tenant-id "${{ vars.AZURE_TENANT_ID }}" `
# --client-id "${{ vars.AZURE_CLIENT_ID }}" `
# --federated-credential-provider "${{ vars.AZD_PIPELINE_PROVIDER }}"

# - name: Setup environment
# if: github.ref == 'refs/heads/main' || github.event_name == 'workflow_dispatch'
# shell: pwsh
# run: |
# # Create config.json under .azure
# New-Item -Type Directory .azure
# $config = @{ version = 1; defaultEnvironment = "${{ vars.AZURE_ENV_NAME }}" }
# $config | ConvertTo-Json -Depth 100 | Out-File -Path ./.azure/config.json -Force

# # Create config.json under .azure/${{ vars.AZURE_ENV_NAME }}
# New-Item -Type Directory .azure/${{ vars.AZURE_ENV_NAME }}
# $config = @{ services = @{ app = @{ config = @{ exposedServices = @( "playground" ) } } } }
# $config | ConvertTo-Json -Depth 100 | Out-File -Path ./.azure/${{ vars.AZURE_ENV_NAME }}/config.json -Force

# # Create .env under .azure/${{ vars.AZURE_ENV_NAME }}
# $dotenv = @()
# $dotenv += "AZD_PIPELINE_PROVIDER=`"${{ vars.AZD_PIPELINE_PROVIDER }}`""
# $dotenv += "AZURE_CONTAINER_APPS_ENVIRONMENT_DEFAULT_DOMAIN=`"${{ vars.AZURE_CONTAINER_APPS_ENVIRONMENT_DEFAULT_DOMAIN }}`""
# $dotenv += "AZURE_CONTAINER_APPS_ENVIRONMENT_ID=`"${{ vars.AZURE_CONTAINER_APPS_ENVIRONMENT_ID }}`""
# $dotenv += "AZURE_CONTAINER_REGISTRY_ENDPOINT=`"${{ vars.AZURE_CONTAINER_REGISTRY_ENDPOINT }}`""
# $dotenv += "AZURE_CONTAINER_REGISTRY_MANAGED_IDENTITY_ID=`"${{ vars.AZURE_CONTAINER_REGISTRY_MANAGED_IDENTITY_ID }}`""
# $dotenv += "AZURE_ENV_NAME=`"${{ vars.AZURE_ENV_NAME }}`""
# $dotenv += "AZURE_LOCATION=`"${{ vars.AZURE_LOCATION }}`""
# $dotenv += "AZURE_PIPELINE_CLIENT_ID=`"${{ vars.AZURE_PIPELINE_CLIENT_ID }}`""
# $dotenv += "AZURE_SUBSCRIPTION_ID=`"${{ vars.AZURE_SUBSCRIPTION_ID }}`""
# $dotenv += "MANAGED_IDENTITY_CLIENT_ID=`"${{ vars.MANAGED_IDENTITY_CLIENT_ID }}`""
# $dotenv += "SERVICE_BINDING_TABLE_ENDPOINT=`"${{ vars.SERVICE_BINDING_TABLE_ENDPOINT }}`""
# $dotenv | Out-File -Path ./.azure/${{ vars.AZURE_ENV_NAME }}/.env -Force

# - name: Update appsettings.json
# if: github.ref == 'refs/heads/main' || github.event_name == 'workflow_dispatch'
# shell: pwsh
# run: |
# $instances = @()
# $aoais = az resource list -g rg-${{ vars.AZURE_ENV_NAME }} --query "[?type=='Microsoft.CognitiveServices/accounts'].name" | ConvertFrom-Json
# $aoais | ForEach-Object {
# $name = $_
# $endpoint = az cognitiveservices account show -g rg-${{ vars.AZURE_ENV_NAME }} -n $name --query "properties.endpoint" -o tsv
# $apiKey = az cognitiveservices account keys list -g rg-${{ vars.AZURE_ENV_NAME }} -n $name --query "key1" -o tsv
# $deploymentName = az cognitiveservices account deployment list -g rg-${{ vars.AZURE_ENV_NAME }} -n $name --query "[].name" -o tsv

# $instance = @{ Endpoint = $endpoint; ApiKey = $apiKey; DeploymentName = $deploymentName }
# $instances += $instance
# }

# Copy-Item -Path ./src/AzureOpenAIProxy.AppHost/appsettings.Development.sample.json `
# -Destination ./src/AzureOpenAIProxy.AppHost/appsettings.Development.json -Force

# $appsettings = Get-Content -Path ./src/AzureOpenAIProxy.AppHost/appsettings.Development.json | ConvertFrom-Json
# $appsettings.AOAI.Instances = $instances
# $appsettings | ConvertTo-Json -Depth 100 | Out-File -Path ./src/AzureOpenAIProxy.AppHost/appsettings.Development.json -Force

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

- name: Install local certs
shell: pwsh
run: |
dotnet dev-certs https --clean
dotnet dev-certs https --trust

- name: Install Aspire workload
shell: pwsh
run: |
Expand All @@ -123,9 +57,22 @@ jobs:
shell: bash
run: |
dotnet test

- name: Install azd
uses: Azure/[email protected]

- name: Log in with Azure (Federated Credentials)
run: |
azd auth login `
--client-id "$Env:AZURE_CLIENT_ID" `
--federated-credential-provider "github" `
--tenant-id "$Env:AZURE_TENANT_ID"
shell: pwsh

- name: Provision Infrastructure
run: azd provision --no-prompt
env:
AZD_INITIAL_ENVIRONMENT_CONFIG: ${{ secrets.AZD_INITIAL_ENVIRONMENT_CONFIG }}

# - name: Deploy to Azure Container Apps
# if: github.ref == 'refs/heads/main' || github.event_name == 'workflow_dispatch'
# shell: pwsh
# run: |
# azd deploy
- name: Deploy Application
run: azd deploy --no-prompt
69 changes: 0 additions & 69 deletions biceps/openAI.bicep

This file was deleted.

78 changes: 0 additions & 78 deletions biceps/openAIModels.bicep

This file was deleted.

36 changes: 0 additions & 36 deletions biceps/openAIs.bicep

This file was deleted.

1 change: 0 additions & 1 deletion biceps/resourceGroup.bicep

This file was deleted.

Loading