5b07757dbc
Bumps [com.google.guava:guava](https://github.com/google/guava) from 30.0-jre to 32.0.0-jre. - [Release notes](https://github.com/google/guava/releases) - [Commits](https://github.com/google/guava/commits) --- updated-dependencies: - dependency-name: com.google.guava:guava dependency-type: direct:production ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> |
||
---|---|---|
.. | ||
Azure.Functions.Java.Tests.E2E | ||
src/main | ||
README.md | ||
confluent_cloud_cacert.pem | ||
host.json | ||
local.settings.json | ||
pom.xml |
README.md
Azure Functions in Java
This repo contains several Java Azure Functions samples for different events.
Prerequisites
- JDK 1.8
- Maven 3.0+
- .NET Core SDK
- An active azure subscription
- Azure Storage Explorer
Usage
Prerequisites
- An Azure Storage Account
- An Azure Service Bus
- An Event Hubs. Under your Event Hubs, create an Event Hub named
myhub
. We will use it in the function example. - An Azure Cosmos DB. Under your Cosmos DB, create a database
db
, in the databasedb
, create a collectioncol
. We will use it in the function example.
Azure Resources and Environmen Variables
- Create following Azure Resources:
- Azure Storage - For testing Blob and Queue triggers
- Add environment variable
AzureWebJobsStorage
with value Azure Storage Connection String
- Add environment variable
- Azure Cosmos DB
- Add environment variable
AzureWebJobsCosmosDBConnectionString
with value Azure CosmosDB Connection String - Create Database :
ItemDb
- Add environment variable
- Azure EventHubs
- Add environment variable
AzureWebJobsEventHubReceiver
with value Azure EventHub Connection String - Add environment variable
AzureWebJobsEventHubSender
with value Azure EventHub Connection String - Create following Event Hubs
test-eventhuboutput-java
test-input-java
test-eventhuboutputjson-java
test-inputjson-java
test-eventhuboutputone-java
test-inputOne-java
- Add environment variable
- Azure Service Bus
- Add environment variable
AzureWebJobsServiceBus
with value Azure Service Connection String - Add environment variable
SBTopicName
with value Service Bus Topic Name - Add environment variable
SBTopicSubName
with value Service Bus Topic Subscription Name - Add environment variable
SBQueueName
with value Service Bus Queue Name
- Add environment variable
- Azure Storage - For testing Blob and Queue triggers
Table Input and Output (Manual tests)
- Open
Azure Storage Explorer
, find your Azure Storage Account. UnderTables
create a table namedPerson
. UnderQueues
create a queue namedmytablequeue
. - In table
Person
, add an entity withPartitionKey=firstPartition, RowKey=firstRow, Name=firstName
. - In queue
mytablequeue
, add a messagefirstRow
, then the Table Input function will get triggered. - Copy the
tableOutput
url from log, then use postman send a POST request with a name, let's saysecond
, in body to this url, the Table Output function will get triggered.
Service Bus Queue Trigger and Output
- Open Azure Portal in web browser, find your Service Bus Namespace. Create a Queue named
mysbqueue
if it doesn't exist. - Copy the
ServiceBusQueueOutput
url from log, then use postman send a POST request with a message in the body to this url, the Event Hub Output function will get triggered. - When Service Bus Queue Output function get triggered and add a message into
mysbqueue
, Service Bus Queue Trigger function will get triggered.
Service Bus Topic Trigger and Output
- Open Azure Portal in web browser, find your Service Bus Namespace. Create a Topic named
mysbtopic
if it doesn't exist. Create a subscription namedmysubs
undermysbtopic
. - Copy the
serviceBusTopicOutput
url from log, then use postman send a POST request with a message in the body to this url, the Event Hub Output function will get triggered. - When Service Bus Topic Output function get triggered and add a message into
mysbtopic
, Service Bus Topic Trigger function will get triggered.
Event Grid Trigger
- To simply trigger this function, you can just use postman to manually post a request:
- Post to the URL of your Event Grid trigger function, using the following pattern:
http://localhost:7071//runtime/webhooks/EventGridExtensionConfig?functionName={functionname}
- Set a
Content-Type: application/json
header - Set an
aeg-event-type: Notification
header. - Paste below data into the request body
[{ "topic": "/subscriptions/{subscriptionid}/resourceGroups/eg0122/providers/Microsoft.Storage/storageAccounts/egblobstore", "subject": "/blobServices/default/containers/{containername}/blobs/blobname.jpg", "eventType": "Microsoft.Storage.BlobCreated", "eventTime": "2018-01-23T17:02:19.6069787Z", "id": "{guid}", "data": { "api": "PutBlockList", "clientRequestId": "{guid}", "requestId": "{guid}", "eTag": "0x8D562831044DDD0", "contentType": "application/octet-stream", "contentLength": 2248, "blobType": "BlockBlob", "url": "https://egblobstore.blob.core.windows.net/{containername}/blobname.jpg", "sequencer": "000000000000272D000000000003D60F", "storageDiagnostics": { "batchId": "{guid}" } }, "dataVersion": "", "metadataVersion": "1" }]
- Post to the URL of your Event Grid trigger function, using the following pattern:
Notes for ExtensionBundle
- In the host file, the extensionBundle part is important, if this part is not there, then when running end2end test, there will be all resources (eventhub, evnetgrid, servicebus…) not registered exception. Also, make sure the version of extensionBundle is always up-to-date.
- Another option to replace extensionBundle is to have file extensions.csproj, if you have this file, then the extensionbundle part can be removed from host.json. What this file do is to create a bin folder under /home/site/wwwroot with all the extensions you are going to need to work with those resources. Notes: make sure the version of the ExtensionsMetadataGenerator in extensions.csproj is update-to-date.