This Connector API App sample provides connectivity to Azure Storage Queue. It provides the following functionalities:
- Get Message
- Delete Message
- Send Message
- Trigger on Message Available
This Connector sample illustrates the following:
- Developing a basic API App
- Adding summary and other annotations from XML Comments
- Dynamically generate swagger based on configuration
- Implementing a basic polling based Trigger
NOTE: This is a sample Connector API App. The purpose of the API App is to illustrate how a Connector can be developed. The codebase, therefore, has bee kept really simple and does not include error handling, validation logic, diagnostic logging, optimizations, etc.
You will need the following to use the sample:
- An Azure Storage account with a couple of Queues
- Visual Studio 2013
- Azure SDK 2.5.1 or above
-
Open web.config and add the necessary Storage Connection string in the following sections:
<appSettings> <add key="StorageConnectionString" value="{add your Storage Connection String here}"/> </appSettings>
-
Open the project in Visual Studio and Build it.
- Run the project (F5 - Start Debugging)
- Navigate to http://localhost:24128/swagger
- Use the Swagger UI to test the operations
Follow the steps in the following tutorial: http://azure.microsoft.com/en-us/documentation/articles/app-service-dotnet-deploy-api-app/
- Create a Logic App in the same Resource Group where you have published this Connector API App.
- Follow the steps here: http://azure.microsoft.com/en-us/documentation/articles/app-service-logic-create-a-logic-app/
HINT: You can configure the Logic App to run manually. Click 'Run Now' to run the Logic App.
The Connector API methods are implemented in the MessagesController class (in the MessagesController.cs file).
It provides the following 3 actions:
- GetMessage: Reads a message from a Queue. The message is not deleted.
- DeleteMessage: Deletes a message that is previously read from a Queue.
- SendMessage: Sends a message to a Queue.
In addition, it implements a trigger:
- NewMessageTrigger: Returns a message from a Queue. Previous message is deleted.
SwaggerConfig class in (SwaggerConfig.cs) defines how the swagger is geenrated. The project is configred to generate XML Comments, and Swagger configuration is configured to use that. It also adds 3 operation filters:
- AddDefaultResponseFilter: Adds a "default" response object
- DiscoverQueueFilter: adds dynamically an enum that lists all the queues in the configured storage account
- TriggerStateFilter: adds extra vendor extension fields for the triggerState parameter