I have a Node.js Azure Function in TypeScript. When I deploy, it takes like 25 minutes to deploy.
Those are pretty basic functions with Prisma ORM. Building locally takes couple seconds only.
Is that normal? I also have the WEBSITE_RUN_FROM_PACKAGE = 1
in my Azure Function configuration.
Here are my project dependencies in my package.json
:
"dependencies": {
"@azure/functions": "^4.0.0",
"@prisma/client": "5.6.0",
"crypto": "^1.0.1",
"jsonwebtoken": "^9.0.2",
"prisma": "^5.6.0"
},
"devDependencies": {
"@types/node": "18.x",
"concurrently": "^8.2.2",
"rimraf": "^5.0.0",
"typescript": "^4.0.0"
}
The problem is likely caused by the new yaml Github Actions that are automatically generated by Azure, which first build, upload, and then download the artifact in the next step to actually deploy it.
This new yaml deployment template is useful when Azure fails to deploy even though your build is correct. My recommendation is to use the 'old' deployment method that does not upload the artifact to any storage rather than the Azure method.
name: xxxxxx
on:
push:
branches:
- xxxx
workflow_dispatch:
env:
AZURE_FUNCTIONAPP_PACKAGE_PATH: '.'
NODE_VERSION: '18.x'
jobs:
build-and-deploy:
runs-on: windows-latest
steps:
- name: 'Checkout GitHub Action'
uses: actions/checkout@v2
- name: Setup Node ${{ env.NODE_VERSION }} Environment
uses: actions/setup-node@v1
with:
node-version: ${{ env.NODE_VERSION }}
- name: 'Resolve Project Dependencies Using Npm'
shell: pwsh
run: |
pushd './${{ env.AZURE_FUNCTIONAPP_PACKAGE_PATH }}'
npm install
npm run build --if-present
npm run test --if-present
popd
- name: 'Run Azure Functions Action'
uses: Azure/functions-action@v1.5.0
id: fa
with:
app-name: 'xxxxxxxx'
slot-name: 'production'
package: ${{ env.AZURE_FUNCTIONAPP_PACKAGE_PATH }}
publish-profile: ${{ secrets.AzureAppService_xxxxxxxxxxxxxx }}