generated from CDCgov/template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Added terraform for an Azure Function to use for polling - Added terraform for polling queue and DLQ - Added function deploy github action - Added function code to, on a CRON schedule, enqueue a message - Updated README Co-authored-by: Samuel Aquino <saquino@flexion.us> Co-authored-by: pluckyswan <96704946+pluckyswan@users.noreply.github.com> Co-authored-by: James Herr <jherr@flexion.us> Co-authored-by: Bella Luz Quintero <bquintero@flexion.us> Co-authored-by: jcrichlake <145698165+jcrichlake@users.noreply.github.com>
- Loading branch information
1 parent
e5c8f5d
commit 85bf105
Showing
20 changed files
with
1,333 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
# TODO - currently this is only called from the `internal` deploy job. It should be part of all envs | ||
name: Deploy Node.js project to Azure Function App | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
ENVIRONMENT: | ||
required: true | ||
type: string | ||
REGISTRY: | ||
required: true | ||
type: string | ||
REPO: | ||
required: true | ||
type: string | ||
APP: | ||
required: true | ||
type: string | ||
secrets: | ||
AZURE_CLIENT_ID: | ||
required: true | ||
AZURE_TENANT_ID: | ||
required: true | ||
AZURE_SUBSCRIPTION_ID: | ||
required: true | ||
AZURE_FUNCTIONAPP_PUBLISH_PROFILE: | ||
required: true | ||
|
||
permissions: | ||
contents: read | ||
|
||
env: | ||
# AZURE_FUNCTIONAPP_NAME has to match the azurerm_linux_function_app's name in functions.tf | ||
AZURE_FUNCTIONAPP_NAME: 'polling-function-${{ inputs.ENVIRONMENT }}' | ||
AZURE_FUNCTIONAPP_PACKAGE_PATH: 'azure_functions' | ||
NODE_VERSION: '20.x' | ||
|
||
jobs: | ||
build-and-deploy: | ||
runs-on: ubuntu-latest | ||
environment: | ||
${{ inputs.ENVIRONMENT }} | ||
permissions: | ||
id-token: write | ||
contents: read | ||
|
||
steps: | ||
- name: 'Checkout GitHub Action' | ||
uses: actions/checkout@v4 | ||
|
||
- name: 'Setup Node ${{ env.NODE_VERSION }} Environment' | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: ${{ env.NODE_VERSION }} | ||
|
||
- name: 'Resolve Project Dependencies Using Npm' | ||
shell: bash | ||
run: | | ||
pushd './${{ env.AZURE_FUNCTIONAPP_PACKAGE_PATH }}' | ||
npm install | ||
npm run build --if-present | ||
npm run test --if-present | ||
popd | ||
- name: 'Login via Azure CLI' | ||
uses: azure/login@v2 | ||
with: | ||
client-id: ${{ secrets.AZURE_CLIENT_ID }} | ||
tenant-id: ${{ secrets.AZURE_TENANT_ID }} | ||
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }} | ||
|
||
- name: 'Get Publish Profile' | ||
run: | | ||
PUBLISH_PROFILE=$(az webapp deployment list-publishing-profiles -g "csels-rsti-${{ inputs.ENVIRONMENT }}-moderate-rg" -n "polling-function-${{ inputs.ENVIRONMENT }}" --xml) | ||
echo "::add-mask::$PUBLISH_PROFILE" | ||
echo "PUBLISH_PROFILE=$PUBLISH_PROFILE" >> $GITHUB_OUTPUT | ||
id: getPublishProfile | ||
|
||
- name: 'Run Azure Functions Action' | ||
uses: Azure/functions-action@v1 | ||
id: azure-function-deploy | ||
with: | ||
app-name: ${{ env.AZURE_FUNCTIONAPP_NAME }} | ||
package: ${{ env.AZURE_FUNCTIONAPP_PACKAGE_PATH }} | ||
publish-profile: ${{ steps.getPublishProfile.outputs.PUBLISH_PROFILE }} | ||
|
||
# TODO: Add a step to report failure on Azure Function App Func creation | ||
# Currently, if there's a bug in the function code or it tries to use an environment variable that doesn't exist | ||
# or has an invalid value, the Github Action Step will complete successfully but the function code will NOT be | ||
# deployed, and any previous version of the function will be removed |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# 9. Typescript and Azure Functions | ||
|
||
Date: 2024-07-15 | ||
|
||
## Decision | ||
|
||
We're using Azure Functions for scheduled tasks. Azure Functions support a CRON | ||
expression trigger, which most other Azure resources do not. Azure Webjobs are | ||
supposed to work with CRON triggers, but don't seem to work well with Linux servers since they are in preview. | ||
|
||
We're using Typescript for Azure Functions. | ||
Go is not well-supported (it requires special handlers). Of the well-supported | ||
language options, Typescript is lighter-weight than Java or C# and more | ||
familiar to the team than Python. | ||
|
||
## Status | ||
|
||
Accepted. |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
*.js.map | ||
*.ts | ||
.git* | ||
.vscode | ||
__azurite_db*__.json | ||
__blobstorage__ | ||
__queuestorage__ | ||
local.settings.json | ||
test | ||
tsconfig.json | ||
node_modules/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"version": "2.0", | ||
"logging": { | ||
"applicationInsights": { | ||
"samplingSettings": { | ||
"isEnabled": true, | ||
"excludedTypes": "Request" | ||
} | ||
} | ||
}, | ||
"extensionBundle": { | ||
"id": "Microsoft.Azure.Functions.ExtensionBundle", | ||
"version": "[4.*, 5.0.0)" | ||
} | ||
} |
Oops, something went wrong.