Skip to content

Commit 90c7136

Browse files
authored
include spi artifacts in this repo. (#15)
* update repo to include spi artifact * update code owner * remove core lib pipeline files * remove parent project src folder * update readme - update pipeline * add CHANGELOG.md & pull request template file * update pipeline * update CI point to test branch from worker * refactor code * update README.md * update repo name to azure-functions-java-additions * minor updates * resolve final comments * change back to dev branch in pipeline tests
1 parent 1c968cc commit 90c7136

File tree

28 files changed

+350
-352
lines changed

28 files changed

+350
-352
lines changed

.github/pull_request_template.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<!-- Please provide all the information below. -->
2+
3+
### Issue describing the changes in this PR
4+
5+
resolves #issue_for_this_pr
6+
7+
### Pull request checklist
8+
9+
* [ ] My changes **do not** require documentation changes
10+
* [ ] Otherwise: Documentation issue linked to PR
11+
* [ ] My changes are added to the `CHANGELOG.md`
12+
* [ ] I have added all required tests (Unit tests, E2E tests)
13+
14+
<!-- Optional: delete if not applicable -->
15+
### Additional information
16+
17+
Additional PR information

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
2323
hs_err_pid*
2424
/.idea/*
25-
/target/*
25+
target
2626
/bin
2727
/.classpath
2828
/.settings/*

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
## azure-functions-java-spi_1.0.0
2+
3+
### New
4+
* to be update
5+
6+
### Updates
7+
* to be update
8+
9+
### Breaking changes
10+
* to be update

README.md

Lines changed: 9 additions & 200 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,12 @@
55
|master|[![Build status](https://ci.appveyor.com/api/projects/status/ebphtfegnposba6w?svg=true)](https://ci.appveyor.com/project/appsvc/azure-functions-java-library?branch=master)|
66
|dev|[![Build status](https://ci.appveyor.com/api/projects/status/ebphtfegnposba6w?svg=true)](https://ci.appveyor.com/project/appsvc/azure-functions-java-library?branch=dev)|
77

8-
# Library for Azure Java Functions
9-
This repo contains library for building Azure Java Functions. Visit the [complete documentation of Azure Functions - Java Developer Guide](https://docs.microsoft.com/en-us/azure/azure-functions/functions-reference-java) for more details.
8+
# Additional artifacts for Azure Java Functions
9+
This repo contains two additional artifacts for building Azure Java Functions.
10+
* [azure-functions-java-core-library](https://github.com/Azure/azure-functions-java-additions/azure-functions-java-core-library)
11+
* [azure-functions-java-spi](https://github.com/Azure/azure-functions-java-additions/azure-functions-java-spi)
12+
13+
For more information about Azure Java Functions please visit the [complete documentation of Azure Functions - Java Developer Guide](https://docs.microsoft.com/en-us/azure/azure-functions/functions-reference-java) for more details.
1014

1115
## azure-functions-maven plugin
1216
[How to use azure-functions-maven plugin to create, update, deploy and test azure java functions](https://docs.microsoft.com/en-us/java/api/overview/azure/maven/azure-functions-maven-plugin/readme?view=azure-java-stable)
@@ -21,207 +25,12 @@ Please see for details on Parent POM https://github.com/Microsoft/maven-java-par
2125

2226
## Summary
2327

24-
Azure Functions is a solution for easily running small pieces of code, or "functions," in the cloud. You can write just the code you need for the problem at hand, without worrying about a whole application or the infrastructure to run it. Functions can make development even more productive.Pay only for the time your code runs and trust Azure to scale as needed. Azure Functions lets you develop [serverless](https://azure.microsoft.com/en-us/solutions/serverless/) applications on Microsoft Azure.
25-
26-
Azure Functions supports triggers, which are ways to start execution of your code, and bindings, which are ways to simplify coding for input and output data. A function should be a stateless method to process input and produce output. Although you are allowed to write instance methods, your function must not depend on any instance fields of the class. You need to make sure all the function methods are `public` accessible and method with annotation @FunctionName is unique as that defines the entry for the the function.
27-
28-
A deployable unit is an uber JAR containing one or more functions (see below), and a JSON file with the list of functions and triggers definitions, deployed to Azure Functions. The JAR can be created in many ways, although we recommend [Azure Functions Maven Plugin](https://docs.microsoft.com/en-us/java/api/overview/azure/maven/azure-functions-maven-plugin/readme), as it provides templates to get you started with key scenarios.
29-
30-
All the input and output bindings can be defined in `function.json` (not recommended), or in the Java method by using annotations (recommended). All the types and annotations used in this document are included in the `azure-functions-java-library` package.
28+
[Azure Functions Summary](https://github.com/Azure/azure-functions-java-library#summary)
3129

3230
### Sample
3331

34-
Here is an example of a HttpTrigger Azure function in Java:
35-
36-
37-
```java
38-
package com.example;
39-
40-
import com.microsoft.azure.functions.annotation.*;
41-
42-
public class Function {
43-
@FunctionName("echo")
44-
public static String echo(@HttpTrigger(name = "req", methods = { HttpMethod.POST }, authLevel = AuthorizationLevel.ANONYMOUS) String in) {
45-
return "Hello, " + in + ".";
46-
}
47-
}
48-
```
49-
50-
### Adding 3rd Party Libraries
51-
52-
Azure Functions supports the use of 3rd party libraries. If using the Maven plugin for Azure Functions, all of your dependencies specified in your `pom.xml` file will be automatically bundled during the `mvn package` step.
53-
54-
## Data Types
55-
56-
You are free to use all the data types in Java for the input and output data, including native types; customized POJO types and specialized Azure types defined in this API. Azure Functions runtime will try its best to convert the actual input value to the type you need (for example, a `String` input will be treated as a JSON string and be parsed to a POJO type defined in your code).
57-
58-
### JSON Support
59-
The POJO types (Java classes) you may define have to be publicly accessible (`public` modifier). POJO properties/fields may be `private`. For example a JSON string `{ "x": 3 }` is able to be converted to the following POJO type:
60-
61-
```java
62-
public class PojoData {
63-
private int x;
64-
}
65-
```
66-
67-
### Other supported types
68-
Binary data is represented as `byte[]` or `Byte[]` in your Azure functions code. And make sure you specify `dataType = "binary"` in the corresponding triggers/bindings.
69-
70-
Empty input values could be `null` as your functions argument, but a recommended way to deal with potential empty values is to use `Optional<T>` type.
71-
72-
73-
## Inputs
74-
75-
Inputs are divided into two categories in Azure Functions: one is the trigger input and the other is the additional input. Trigger input is the input who triggers your function. And besides that, you may also want to get inputs from other sources (like a blob), that is the additional input.
76-
77-
Let's take the following code snippet as an example:
78-
79-
```java
80-
package com.example;
81-
82-
import com.microsoft.azure.functions.annotation.*;
83-
84-
public class Function {
85-
@FunctionName("echo")
86-
public String echo(
87-
@HttpTrigger(name = "req", methods = { HttpMethod.PUT }, authLevel = AuthorizationLevel.ANONYMOUS, route = "items/{id}") String in,
88-
@TableInput(name = "item", tableName = "items", partitionKey = "example", rowKey = "{id}", connection = "AzureWebJobsStorage") TestInputData inputData
89-
) {
90-
return "Hello, " + in + " and " + inputData.getRowKey() + ".";
91-
}
92-
93-
}
94-
95-
public class TestInputData {
96-
public String getRowKey() { return this.rowKey; }
97-
private String rowKey;
98-
}
99-
100-
```
101-
102-
When this function is invoked, the HTTP request payload will be passed as the `String` for argument `in`; and one entry will be retrieved from the Azure Table Storage and be passed to argument `inputData` as `TestInputData` type.
103-
104-
To receive events in a batch when using EventHubTrigger, set cardinality to many and change input type to an array or List<>
105-
106-
```java
107-
@FunctionName("ProcessIotMessages")
108-
public void processIotMessages(
109-
@EventHubTrigger(name = "message", eventHubName = "%AzureWebJobsEventHubPath%", connection = "AzureWebJobsEventHubSender", cardinality = Cardinality.MANY) List<TestEventData> messages,
110-
final ExecutionContext context)
111-
{
112-
context.getLogger().info("Java Event Hub trigger received messages. Batch size: " + messages.size());
113-
}
114-
115-
public class TestEventData {
116-
public String id;
117-
}
118-
119-
```
120-
121-
Note: You can also bind to String[], TestEventData[] or List<String>
122-
123-
## Outputs
124-
125-
Outputs can be expressed in return value or output parameters. If there is only one output, you are recommended to use the return value. For multiple outputs, you have to use **output parameters**.
126-
127-
Return value is the simplest form of output, you just return the value of any type, and Azure Functions runtime will try to marshal it back to the actual type (such as an HTTP response). You could apply any *output annotations* to the function method (the `name` property of the annotation has to be `$return`) to define the return value output.
128-
129-
For example, a blob content copying function could be defined as the following code. `@StorageAccount` annotation is used here to prevent the duplicating of the `connection` property for both `@BlobTrigger` and `@BlobOutput`.
130-
131-
```java
132-
package com.example;
133-
134-
import com.microsoft.azure.functions.annotation.*;
135-
136-
public class Function {
137-
@FunctionName("copy")
138-
@StorageAccount("AzureWebJobsStorage")
139-
@BlobOutput(name = "$return", path = "samples-output-java/{name}")
140-
public String copy(@BlobTrigger(name = "blob", path = "samples-input-java/{name}") String content) {
141-
return content;
142-
}
143-
}
144-
```
145-
146-
To produce multiple output values, use `OutputBinding<T>` type defined in the `azure-functions-java-library` package. If you need to make an HTTP response and push a message to a queue, you can write something like:
147-
148-
```java
149-
package com.example;
150-
151-
import com.microsoft.azure.functions.*;
152-
import com.microsoft.azure.functions.annotation.*;
153-
154-
public class Function {
155-
@FunctionName("push")
156-
public String push(
157-
@HttpTrigger(name = "req", methods = { HttpMethod.POST }, authLevel = AuthorizationLevel.ANONYMOUS) String body,
158-
@QueueOutput(name = "message", queueName = "myqueue", connection = "AzureWebJobsStorage") OutputBinding<String> queue
159-
) {
160-
queue.setValue("This is the queue message to be pushed");
161-
return "This is the HTTP response content";
162-
}
163-
}
164-
```
165-
166-
Use `OutputBinding<byte[]>` type to make a binary output value (for parameters); for return values, just use `byte[]`.
167-
168-
## Execution Context
169-
170-
You interact with Azure Functions execution environment via the `ExecutionContext` object defined in the `azure-functions-java-library` package. You are able to get the invocation ID, the function name and a built-in logger (which is integrated prefectly with Azure Function Portal experience as well as AppInsights) from the context object.
171-
172-
What you need to do is just add one more `ExecutionContext` typed parameter to your function method. Let's take a timer triggered function as an example:
173-
174-
```java
175-
package com.example;
176-
177-
import com.microsoft.azure.functions.*;
178-
import com.microsoft.azure.functions.annotation.*;
179-
180-
public class Function {
181-
@FunctionName("heartbeat")
182-
public static void heartbeat(
183-
@TimerTrigger(name = "schedule", schedule = "*/30 * * * * *") String timerInfo,
184-
ExecutionContext context
185-
) {
186-
context.getLogger().info("Heartbeat triggered by " + context.getFunctionName());
187-
}
188-
}
189-
```
190-
191-
192-
## Specialized Data Types
193-
194-
### HTTP Request and Response
195-
196-
Sometimes a function need to take a more detailed control of the input and output, and that's why we also provide some specialized types in the `azure-functions-java-library` package for you to manipulate:
197-
198-
| Specialized Type | Target | Typical Usage |
199-
| ------------------------ | :-----------------: | ------------------------------ |
200-
| `HttpRequestMessage<T>` | HTTP Trigger | Get method, headers or queries |
201-
| `HttpResponseMessage` | HTTP Output Binding | Return status other than 200 |
202-
203-
### Metadata
204-
205-
Metadata comes from different sources, like HTTP headers, HTTP queries, and [trigger metadata](https://docs.microsoft.com/en-us/azure/azure-functions/functions-triggers-bindings#trigger-metadata-properties). You can use `@BindingName` annotation together with the metadata name to get the value.
206-
207-
For example, the `queryValue` in the following code snippet will be `"test"` if the requested URL is `http://{example.host}/api/metadata?name=test`.
208-
209-
```java
210-
package com.example;
211-
212-
import java.util.Optional;
213-
import com.microsoft.azure.functions.annotation.*;
214-
215-
public class Function {
216-
@FunctionName("metadata")
217-
public static String metadata(
218-
@HttpTrigger(name = "req", methods = { HttpMethod.GET, HttpMethod.POST }, authLevel = AuthorizationLevel.ANONYMOUS) Optional<String> body,
219-
@BindingName("name") String queryValue
220-
) {
221-
return body.orElse(queryValue);
222-
}
223-
}
224-
```
32+
For samples of Azure function in Java please refer to [Azure Function Java Samples](https://github.com/Azure/azure-functions-java-library#sample)
33+
and [Azure Functions Java Samples Repository](https://github.com/Azure-Samples/azure-functions-samples-java)
22534

22635
### License
22736

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
![Azure Functions Logo](https://raw.githubusercontent.com/Azure/azure-functions-cli/master/src/Azure.Functions.Cli/npm/assets/azure-functions-logo-color-raster.png)
2+
3+
# Core library for Azure Java Functions
4+
This repo contains core library for building Azure Java Functions. `azure-functions-java-core-library` contains base class for building Azure Java Functions.
5+
However, you don't need to include `azure-functions-java-core-library` as a dependency when you build your function app, because it comes with [azure-functions-java-library](https://github.com/Azure/azure-functions-java-library)
6+
which has a transitive dependency on `azure-functions-java-core-library`
7+
8+
For more information about Azure Java Functions please visit the [complete documentation of Azure Functions - Java Developer Guide](https://docs.microsoft.com/en-us/azure/azure-functions/functions-reference-java).
9+
10+
## azure-functions-maven plugin
11+
[How to use azure-functions-maven plugin to create, update, deploy and test azure java functions](https://docs.microsoft.com/en-us/java/api/overview/azure/maven/azure-functions-maven-plugin/readme?view=azure-java-stable)
12+
13+
## Prerequisites
14+
15+
* Java 8
16+
17+
## Summary
18+
19+
[Azure Functions Summary](https://github.com/Azure/azure-functions-java-library#summary)
20+
21+
### Sample
22+
23+
For samples of Azure function in Java please refer to [Azure Function Java Samples](https://github.com/Azure/azure-functions-java-library#sample)
24+
and [Azure Functions Java Samples Repository](https://github.com/Azure-Samples/azure-functions-samples-java)
25+
26+
### License
27+
28+
This project is under the benevolent umbrella of the [.NET Foundation](http://www.dotnetfoundation.org/) and is licensed under [the MIT License](LICENSE.txt)
29+
30+
This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or contact [[email protected]](mailto:[email protected]) with any additional questions or comments.

0 commit comments

Comments
 (0)