I have an azure function that works great in JS but I've migrated the code to TS. When I run the deployment I do see the dist folder generated by TS, however, if I go to the Azure portal I still see my old JS function but there's no sign of the dist folder. I have confirmed through Kudu that the dist folder exists and it contains the new code.
How can I let know to the Azure function to read from the dist folder?
This is my current folder structure:
- Project
- azure_func
- main_func_app
- funcs
-func_js
index.js
my_ref_vals.json
function.json
-func_ts
index.ts
my_ref_vals.json
function.json
-dist
-func_ts
index.js
index.js.map
package.json
host.json
tsconfig.json
Contents of the tsconfig.json
{
"compilerOptions": {
"module": "commonjs",
"target": "es6",
"outDir": "dist",
"rootDir": ".",
"sourceMap": true,
"strict": true
},
"include": ["./**/*.ts"],
"exclude": ["dist", "node_modules"]
}
Contents of the package.json
{
"version": "0.0.0",
"description": "",
"scripts": {
"build": "tsc",
"watch": "tsc -w",
"prestart": "npm run build",
"start": "func host start --typescript",
"test": "echo \"No tests yet...\"",
"lint": "eslint .",
"format": "prettier --write ."
},
"devDependencies":{
"@types/jest": "^28.1.6",
"@types/node": "16.x",
"@typescript-eslint/eslint-plugin": "^5.31.0",
"@typescript-eslint/parser": "^5.31.0",
"eslint": "^8.20.0",
"eslint-config-prettier": "^8.5.0",
}
}
Deployment file:
- stage: Build
displayName: Build stage for Azure Function
jobs:
- job: Build
displayName: Build
pool:
vmImage: $(vmImageName)
steps:
- task: NodeTool@0
inputs:
versionSpec: '14.x'
displayName: 'Install Node.js'
- task: AzureCLI@2
inputs:
azureSubscription: 'mysub-test-group-SPN'
scriptType: 'bash'
scriptLocation: 'inlineScript'
inlineScript: |
npm install
npm run build
- task: ArchiveFiles@2
displayName: 'Create artifact'
inputs:
rootFolderOrFile: 'Project/azure_func/main_func_app/funcs'
includeRootFolder: false
archiveType: zip
archiveFile: $(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip
replaceExistingArchive: true
- upload: $(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip
displayName: 'Publish Azure Functions Artifact'
artifact: functions
- task: AzureFunctionApp@1
displayName: 'Deploy Azure Functions'
inputs:
azureSubscription: 'mysub-test-group-SPN'
appType: 'functionApp'
appName: 'azure_funcs'
package: '$(Pipeline.Workspace)/functions/$(Build.BuildId).zip'
deploymentMethod: 'auto'
Please, comment if something isn't clear.
from How to make an azure function to read from the dist folder generated by Typescript?
No comments:
Post a Comment