Monday, 5 August 2019

azure function java

azure function mvn plugin:

all command from this plugin (very usefull!!!!)

auzre function java sample:

setup from mvn archtype:

if you have issue, you may need to:

azure cli if you have multi subscriptions:

after that you can deploy to azure function from local by mvn.

if you want to use devops:

then you just need to add a mvn pipeline, then add an azure function deployment , or just azure web service deployment.

pool: name: Hosted Ubuntu 1604 demands: maven #Your build pipeline references an undefined variable named ‘Parameters.mavenPOMFile’. Create or edit the build pipeline for this YAML file, define the variable on the Variables tab. See steps: - task: Maven@3 displayName: 'Maven pom.xml' inputs: mavenPomFile: '$(Parameters.mavenPOMFile)' - task: CopyFiles@2 displayName: 'Copy Files to: $(build.artifactstagingdirectory)' inputs: SourceFolder: '$(system.defaultworkingdirectory)' Contents: '**/azure-functions/**' TargetFolder: '$(build.artifactstagingdirectory)' condition: succeededOrFailed() - task: AzureRmWebAppDeployment@4 displayName: 'Azure App Service Deploy: fabrikam-functions-20190805215824801' inputs: azureSubscription: 'sandbox fto' appType: functionApp WebAppName: 'fabrikam-functions-20190805215824801' packageForLinux: '$(build.artifactstagingdirectory)/target/azure-functions/fabrikam-functions-20190805215824801' enableCustomDeployment: true DeploymentType: runFromZip - task: PublishBuildArtifacts@1 displayName: 'Publish Artifact: drop' inputs: PathtoPublish: '$(build.artifactstagingdirectory)' condition: succeededOrFailed()

in about deployment:
  deploymentMethod: zipDeploy
DeploymentType: runFromZip

both ok.

Note: you don't need to zip the whole folder (nodejs project can do with zip file) zip file doesn't work for java project, you just need to list the function folder:

target/azure-functions/your function name.

it is interesting to know that:
mvn local deployment can check if function and resources are not exist it will auto create them. (because it has azure cli integration, it login with you account and create them)

but dev ops need to have them ready first, and in your pipeline, you have to have the function name in the url. which means if you created a new function instance and you got a new function name, then you will need to change your pipeline.

check below link later:

zip deploy:

vs code:


build java application:

predefined vars:

event hub:

azure sprint boot:

sprintboot ide:

mircosoft sprint boot sample:

here has sprint boot sample with azure cosmos and other services: