Monday, 5 August 2019

azure function java


azure function mvn plugin:


https://docs.microsoft.com/en-us/java/api/overview/azure/maven/azure-functions-maven-plugin/readme?view=azure-java-stable

https://github.com/Microsoft/azure-maven-plugins/blob/master/azure-functions-maven-plugin/README.md

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

auzre function java sample:

https://github.com/microsoft/function-demo-java-on-azure


setup from mvn archtype:
https://docs.microsoft.com/en-us/azure/azure-functions/functions-create-first-java-maven


if you have issue, you may need to:

azure cli if you have multi subscriptions:
https://docs.microsoft.com/en-us/cli/azure/manage-azure-subscriptions-azure-cli?view=azure-cli-latest


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 https://go.microsoft.com/fwlink/?linkid=865972 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
  or
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:

https://docs.microsoft.com/en-us/azure/devops/pipelines/tasks/deploy/azure-function-app?view=azure-devops

zip deploy:

https://docs.microsoft.com/en-us/azure/azure-functions/functions-deployment-technologies#zip-deploy



-----
vs code:
https://code.visualstudio.com/docs/java/java-azurefunctions


devops:

build java application:
https://docs.microsoft.com/en-us/azure/devops/pipelines/languages/java?view=azure-devops

predefined vars:
https://docs.microsoft.com/en-us/azure/devops/pipelines/build/variables?view=azure-devops&tabs=yaml

https://docs.microsoft.com/en-us/azure/devops/pipelines/tasks/deploy/azure-function-app?view=azure-devops

---
event hub:
https://github.com/microsoft/inventory-hub-java-on-azure



----
azure sprint boot:

https://spring.io/guides/gs/spring-boot-for-azure/

sprintboot ide:
https://spring.io/tools


mircosoft sprint boot sample:

https://github.com/microsoft/azure-spring-boot/tree/master/azure-spring-boot-samples/azure-cosmosdb-spring-boot-sample

https://github.com/microsoft/azure-spring-boot/tree/master/azure-spring-boot-samples

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

https://github.com/microsoft/azure-spring-boot






2 comments: