Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
GitHub Copilot for Azure plugin providing Azure service management and development assistance inside Claude Code and IDEs.
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
references/services/functions/runtimes/java.md
1# Java — Azure Functions Triggers & Bindings23> **Model**: Java annotation-based model. Uses `@FunctionName` and trigger/binding annotations.4> Import: `com.microsoft.azure.functions.*` and `com.microsoft.azure.functions.annotation.*`56## HTTP Trigger78```java9@FunctionName("HttpFunction")10public HttpResponseMessage run(11@HttpTrigger(name = "req", methods = {HttpMethod.GET, HttpMethod.POST},12authLevel = AuthorizationLevel.ANONYMOUS) HttpRequestMessage<Optional<String>> request,13final ExecutionContext context) {14String name = request.getQueryParameters().get("name");15return request.createResponseBuilder(HttpStatus.OK).body("Hello, " + name).build();16}17```1819## Blob Storage2021```java22// Trigger23@FunctionName("BlobTrigger")24public void run(25@BlobTrigger(name = "blob", path = "samples-workitems/{name}",26connection = "AzureWebJobsStorage") byte[] content,27@BindingName("name") String name,28final ExecutionContext context) {29context.getLogger().info("Blob: " + name + ", Size: " + content.length);30}3132// Input33@BlobInput(name = "inputBlob", path = "input/{name}", connection = "AzureWebJobsStorage")3435// Output36@BlobOutput(name = "outputBlob", path = "output/{name}-out", connection = "AzureWebJobsStorage")37```3839## Queue Storage4041```java42// Trigger43@FunctionName("QueueTrigger")44public void run(45@QueueTrigger(name = "message", queueName = "myqueue-items",46connection = "AzureWebJobsStorage") String message,47final ExecutionContext context) {48context.getLogger().info("Queue message: " + message);49}5051// Output52@QueueOutput(name = "output", queueName = "outqueue", connection = "AzureWebJobsStorage")53```5455## Timer5657```java58@FunctionName("TimerFunction")59public void run(60@TimerTrigger(name = "timer", schedule = "0 */5 * * * *") String timerInfo,61final ExecutionContext context) {62context.getLogger().info("Timer triggered");63}64```6566## Event Grid6768```java69// Trigger70@FunctionName("EventGridTrigger")71public void run(72@EventGridTrigger(name = "event") EventGridEvent event,73final ExecutionContext context) {74context.getLogger().info("Event: " + event.subject());75}7677// Output78@EventGridOutput(name = "output", topicEndpointUri = "MyTopicUri",79topicKeySetting = "MyTopicKey")80```8182## Cosmos DB8384```java85// Trigger (Change Feed)86@FunctionName("CosmosDBTrigger")87public void run(88@CosmosDBTrigger(name = "documents", databaseName = "mydb",89containerName = "mycontainer", connection = "CosmosDBConnection",90createLeaseContainerIfNotExists = true) String[] documents,91final ExecutionContext context) {92for (String doc : documents) context.getLogger().info("Doc: " + doc);93}9495// Input96@CosmosDBInput(name = "doc", databaseName = "mydb", containerName = "mycontainer",97connection = "CosmosDBConnection", id = "{id}", partitionKey = "{pk}")9899// Output100@CosmosDBOutput(name = "newdoc", databaseName = "mydb", containerName = "mycontainer",101connection = "CosmosDBConnection")102```103104## Service Bus105106```java107// Queue Trigger108@FunctionName("SBQueueTrigger")109public void run(110@ServiceBusQueueTrigger(name = "message", queueName = "myqueue",111connection = "ServiceBusConnection") String message,112final ExecutionContext context) {113context.getLogger().info("Message: " + message);114}115116// Topic Trigger117@FunctionName("SBTopicTrigger")118public void run(119@ServiceBusTopicTrigger(name = "message", topicName = "mytopic",120subscriptionName = "mysubscription",121connection = "ServiceBusConnection") String message,122final ExecutionContext context) {123context.getLogger().info("Topic: " + message);124}125126// Output127@ServiceBusQueueOutput(name = "output", queueName = "outqueue",128connection = "ServiceBusConnection")129```130131## Event Hubs132133```java134// Trigger135@FunctionName("EventHubTrigger")136public void run(137@EventHubTrigger(name = "event", eventHubName = "myeventhub",138connection = "EventHubConnection", cardinality = Cardinality.MANY) List<String> events,139final ExecutionContext context) {140events.forEach(e -> context.getLogger().info("Event: " + e));141}142143// Output144@EventHubOutput(name = "output", eventHubName = "outeventhub",145connection = "EventHubConnection")146```147148## Table Storage149150```java151// Input152@TableInput(name = "entity", tableName = "mytable", partitionKey = "{pk}",153rowKey = "{rk}", connection = "AzureWebJobsStorage")154155// Output156@TableOutput(name = "output", tableName = "mytable", connection = "AzureWebJobsStorage")157```158159## SQL160161```java162// Trigger163@FunctionName("SqlTrigger")164public void run(165@SqlTrigger(name = "changes", tableName = "dbo.MyTable",166connectionStringSetting = "SqlConnection") SqlChange[] changes,167final ExecutionContext context) {168for (SqlChange change : changes) context.getLogger().info("Change: " + change);169}170171// Input172@SqlInput(name = "items", commandText = "SELECT * FROM dbo.MyTable WHERE Id = @Id",173commandType = "Text", parameters = "@Id={id}",174connectionStringSetting = "SqlConnection")175176// Output177@SqlOutput(name = "output", commandText = "dbo.MyTable",178connectionStringSetting = "SqlConnection")179```180181## SignalR182183```java184@SignalROutput(name = "signalr", hubName = "myhub",185connectionStringSetting = "AzureSignalRConnectionString")186```187188## SendGrid189190```java191@SendGridOutput(name = "mail", apiKey = "SendGridApiKey",192from = "[email protected]", to = "{email}")193```194195## Multiple Outputs196197Java uses `OutputBinding<T>` for additional outputs:198199```java200@FunctionName("MultiOutput")201public HttpResponseMessage run(202@HttpTrigger(name = "req", methods = {HttpMethod.POST},203authLevel = AuthorizationLevel.ANONYMOUS) HttpRequestMessage<String> request,204@QueueOutput(name = "output", queueName = "outqueue",205connection = "AzureWebJobsStorage") OutputBinding<String> queueOutput,206final ExecutionContext context) {207queueOutput.setValue("new item");208return request.createResponseBuilder(HttpStatus.OK).body("Processed").build();209}210```211212> **Note**: Java uses `function.json` generated at build time by the Maven plugin — you don't write them manually.213214> Full reference: [Azure Functions Java developer guide](https://learn.microsoft.com/en-us/azure/azure-functions/functions-reference-java)215