You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/azure-functions/functions-add-output-binding-storage-queue-java.md
+22-2Lines changed: 22 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,8 +1,11 @@
1
1
---
2
2
title: Connect your Java function to Azure Storage
3
3
description: Learn how to connect an HTTP-triggered Java function to Azure Storage by using a Queue storage output binding.
4
+
author: KarlErickson
5
+
ms.author: karler
4
6
ms.date: 10/14/2019
5
7
ms.topic: quickstart
8
+
zone_pivot_groups: java-build-tools-set
6
9
---
7
10
8
11
# Connect your Java function to Azure Storage
@@ -107,10 +110,19 @@ You're now ready to try out the new output binding locally.
107
110
108
111
As before, use the following command to build the project and start the Functions runtime locally:
109
112
113
+
::: zone pivot="java-build-tools-maven"
110
114
```bash
111
115
mvn clean package
112
116
mvn azure-functions:run
113
117
```
118
+
::: zone-end
119
+
120
+
::: zone pivot="java-build-tools-gradle"
121
+
```bash
122
+
gradle jar --info
123
+
gradle azureFunctionsRun
124
+
```
125
+
::: zone-end
114
126
115
127
> [!NOTE]
116
128
> Because you enabled extension bundles in the host.json, the [Storage binding extension](functions-bindings-storage-blob.md#add-to-your-functions-app) was downloaded and installed for you during startup, along with the other Microsoft binding extensions.
@@ -133,9 +145,17 @@ Next, you use the Azure CLI to view the new queue and verify that a message was
133
145
134
146
To update your published app, run the following command again:
135
147
136
-
```azurecli
148
+
::: zone pivot="java-build-tools-maven"
149
+
```bash
137
150
mvn azure-functions:deploy
138
151
```
152
+
::: zone-end
153
+
154
+
::: zone pivot="java-build-tools-gradle"
155
+
```bash
156
+
gradle azureFunctionsDeploy
157
+
```
158
+
::: zone-end
139
159
140
160
Again, you can use cURL to test the deployed function. As before, pass the value `AzureFunctions` in the body of the POST request to the URL, as in this example:
141
161
@@ -157,4 +177,4 @@ Next, you should enable Application Insights monitoring for your function app:
# Quickstart: Use Java and Maven to create and publish a function to Azure
12
+
# Quickstart: Use Java and Maven/Gradle to create and publish a function to Azure
11
13
12
-
This article shows you how to build and publish a Java function to Azure Functions with the Maven command-line tool. When you're done, your function code runs in Azure in a [serverless hosting plan](functions-scale.md#consumption-plan) and is triggered by an HTTP request.
14
+
This article shows you how to build and publish a Java function to Azure Functions with the Maven/Gradle command-line tool. When you're done, your function code runs in Azure in a [serverless hosting plan](functions-scale.md#consumption-plan) and is triggered by an HTTP request.
13
15
14
16
<!--
15
17
> [!NOTE]
@@ -21,44 +23,36 @@ This article shows you how to build and publish a Java function to Azure Functio
21
23
To develop functions using Java, you must have the following installed:
22
24
23
25
-[Java Developer Kit](https://aka.ms/azure-jdks), version 8
24
-
-[Apache Maven](https://maven.apache.org), version 3.0 or above
25
26
-[Azure CLI]
26
27
-[Azure Functions Core Tools](./functions-run-local.md#v2) version 2.6.666 or above
28
+
::: zone pivot="java-build-tools-maven"
29
+
-[Apache Maven](https://maven.apache.org), version 3.0 or above
30
+
::: zone-end
31
+
32
+
::: zone pivot="java-build-tools-gradle"
33
+
-[Gradle](https://gradle.org/), version 4.10 and above
34
+
::: zone-end
27
35
28
36
You also need an active Azure subscription. [!INCLUDE [quickstarts-free-trial-note](../../includes/quickstarts-free-trial-note.md)]
29
37
30
38
31
39
> [!IMPORTANT]
32
40
> The JAVA_HOME environment variable must be set to the install location of the JDK to complete this quickstart.
33
41
34
-
## Generate a new Functions project
42
+
## Prepare a Functions project
35
43
44
+
::: zone pivot="java-build-tools-maven"
36
45
In an empty folder, run the following command to generate the Functions project from a [Maven archetype](https://maven.apache.org/guides/introduction/introduction-to-archetypes.html).
> If you're experiencing issues with running the command, take a look at what `maven-archetype-plugin` version is used. Because you are running the command in an empty directory with no `.pom` file, it might be attempting to use a plugin of the older version from `~/.m2/repository/org/apache/maven/plugins/maven-archetype-plugin` if you upgraded your Maven from an older version. If so, try deleting the `maven-archetype-plugin` directory and re-running the command.
52
+
> If you're using Powershell, remeber to add "" around parameters.
48
53
49
-
### Windows
50
-
51
-
```powershell
52
-
mvn archetype:generate `
53
-
"-DarchetypeGroupId=com.microsoft.azure" `
54
-
"-DarchetypeArtifactId=azure-functions-archetype"
55
-
```
56
-
57
-
```cmd
58
-
mvn archetype:generate ^
59
-
"-DarchetypeGroupId=com.microsoft.azure" ^
60
-
"-DarchetypeArtifactId=azure-functions-archetype"
61
-
```
54
+
> [!NOTE]
55
+
> If you're experiencing issues with running the command, take a look at what `maven-archetype-plugin` version is used. Because you are running the command in an empty directory with no `.pom` file, it might be attempting to use a plugin of the older version from `~/.m2/repository/org/apache/maven/plugins/maven-archetype-plugin` if you upgraded your Maven from an older version. If so, try deleting the `maven-archetype-plugin` directory and re-running the command.
62
56
63
57
Maven asks you for values needed to finish generating the project on deployment. Provide the following values when prompted:
64
58
@@ -74,7 +68,35 @@ Maven asks you for values needed to finish generating the project on deployment.
74
68
75
69
Type `Y` or press Enter to confirm.
76
70
77
-
Maven creates the project files in a new folder with a name of _artifactId_, which in this example is `fabrikam-functions`.
71
+
Maven creates the project files in a new folder with a name of _artifactId_, which in this example is `fabrikam-functions`. Run the following command to change the directory to the created project folder.
72
+
```bash
73
+
cd fabrikam-function
74
+
```
75
+
76
+
::: zone-end
77
+
::: zone pivot="java-build-tools-gradle"
78
+
Use the following command to clone the sample project:
Open the new Function.java file from the *src/main/java* path in a text editor and review the generated code. This code is an [HTTP triggered](functions-bindings-http-webhook.md) function that echoes the body of the request.
80
102
@@ -83,15 +105,23 @@ Open the new Function.java file from the *src/main/java* path in a text editor a
83
105
84
106
## Run the function locally
85
107
86
-
Run the following command, which changes the directory to the newly created project folder, then builds and runs the function project:
108
+
Run the following commandto build then run the function project:
87
109
88
-
```console
89
-
cd fabrikam-function
110
+
::: zone pivot="java-build-tools-maven"
111
+
```bash
90
112
mvn clean package
91
113
mvn azure-functions:run
92
114
```
115
+
::: zone-end
116
+
117
+
::: zone pivot="java-build-tools-gradle"
118
+
```bash
119
+
gradle jar --info
120
+
gradle azureFunctionsRun
121
+
```
122
+
::: zone-end
93
123
94
-
You see output like the following from Azure Functions Core Tools when you run the project locally:
124
+
You will see output like the following from Azure Functions Core Tools when you run the project locally:
95
125
96
126
```output
97
127
...
@@ -107,7 +137,7 @@ Http Functions:
107
137
108
138
Trigger the function from the command line using cURL in a new terminal window:
> If your account can access multiple subscriptions, use [az account set](/cli/azure/account#az-account-set) to set the default subscription for this session.
132
162
133
-
Use the following Maven command to deploy your project to a new function app.
163
+
Use the following command to deploy your project to a new function app.
134
164
135
-
```console
165
+
166
+
::: zone pivot="java-build-tools-maven"
167
+
```bash
136
168
mvn azure-functions:deploy
137
169
```
170
+
::: zone-end
171
+
172
+
::: zone pivot="java-build-tools-gradle"
173
+
```bash
174
+
gradle azureFunctionsDeploy
175
+
```
176
+
::: zone-end
138
177
139
-
This `azure-functions:deploy` Maven target creates the following resources in Azure:
178
+
This will create the following resources in Azure:
140
179
141
180
+ Resource group. Named with the _resourceGroup_ you supplied.
142
181
+ Storage account. Required by Functions. The name is generated randomly based on Storage account name requirements.
0 commit comments