Getting started Community Training Tutorials Documentation APIs, AI & Tools
The following examples show several Mule flows for Azure Cosmos DB Connector:
| Some operations require existing documents, stored procedures, or permissions, which can be created with their respective flows. |
This Mule flow creates a new document or replaces an existing one.
This example uses the following operations:
HTTP Listener
Accepts data from HTTP requests
Create Document
Creates a new document in a collection
Transform Message
Outputs the results of the Create Document operation in JSON format
Logger
Shows the HTTP response from the Create Document operation
Paste this code into the Studio XML editor to quickly load the flow for this example into your Mule app:
<?xml version="1.0" encoding="UTF-8"?>
<mule
xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
xmlns:azure-cosmos-db-connector-mule-4="http://www.mulesoft.org/schema/mule/azure-cosmos-db-connector-mule-4"
xmlns:ee="http://www.mulesoft.org/schema/mule/ee/core" xmlns:http="http://www.mulesoft.org/schema/mule/http"
xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
http://www.mulesoft.org/schema/mule/ee/core http://www.mulesoft.org/schema/mule/ee/core/current/mule-ee.xsd
http://www.mulesoft.org/schema/mule/azure-cosmos-db-connector-mule-4 http://www.mulesoft.org/schema/mule/azure-cosmos-db-connector-mule-4/current/mule-azure-cosmos-db-connector-mule-4.xsd">
<configuration-properties file="mule-app.properties"/>
<http:listener-config name="HTTP_Listener_config">
<http:listener-connection host="0.0.0.0" port="8081"/>
</http:listener-config>
<azure-cosmos-db-connector-mule-4:key-token-config name="Cosmos_Db_Connector_Config">
<azure-cosmos-db-connector-mule-4:key-token-auth-connection key="${config.myKey}"
version="${config.version}"
baseUri="${config.baseUri}"/>
</azure-cosmos-db-connector-mule-4:key-token-config>
<azure-cosmos-db-connector-mule-4:resource-token-config name="Cosmos_Db_Connector_Config_Resource_Token">
<azure-cosmos-db-connector-mule-4:resource-token-auth-connection resourceToken="#[vars.resourceToken]"
version="${config.version}"
baseUri="${config.baseUri}"/>
</azure-cosmos-db-connector-mule-4:resource-token-config>
<flow name="create-document-flow">
<http:listener config-ref="HTTP_Listener_config" path="/create-document"/>
<azure-cosmos-db-connector-mule-4:create-document config-ref="Cosmos_Db_Connector_Config"
dbIdUriParam="${config.database}"
collIdUriParam="${config.collection}"
xMsDocumentdbPartitionkeyHeader="#[write(['Mule_CosmosDB_DemoApp_DocumentId'], 'application/json')]"
xMsIndexingDirectiveHeader="INCLUDE">
<azure-cosmos-db-connector-mule-4:create-document-body>
<![CDATA[#[%dw 2.0
output application/json
---
{
"id" : "Mule_CosmosDB_DemoApp_DocumentId",
"firstName" : "John",
"lastName" : "Smith"
}]]]></azure-cosmos-db-connector-mule-4:create-document-body>
</azure-cosmos-db-connector-mule-4:create-document>
<ee:transform>
<ee:message>
<ee:set-payload><![CDATA[%dw 2.0
output application/json
---
payload]]></ee:set-payload>
</ee:message>
</ee:transform>
<logger level="INFO" message="#[payload]"/>
</flow>
</mule>
Verify that your connector is configured.
Save the project.
From a web browser, test the application by entering http://localhost:8081/create-document.
This Mule flow retrieves an existing document.
This example uses the following operations:
HTTP Listener
Accepts data from HTTP requests
Get Document
Retrieves a document by its partition key and document key
Transform Message
Outputs the results of the Get Document operation in JSON format
Logger
Shows the HTTP response from the Get Document operation
Paste this code into the Studio XML editor to quickly load the flow for this example into your Mule app:
<?xml version="1.0" encoding="UTF-8"?>
<mule
xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
xmlns:azure-cosmos-db-connector-mule-4="http://www.mulesoft.org/schema/mule/azure-cosmos-db-connector-mule-4"
xmlns:ee="http://www.mulesoft.org/schema/mule/ee/core" xmlns:http="http://www.mulesoft.org/schema/mule/http"
xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
http://www.mulesoft.org/schema/mule/ee/core http://www.mulesoft.org/schema/mule/ee/core/current/mule-ee.xsd
http://www.mulesoft.org/schema/mule/azure-cosmos-db-connector-mule-4 http://www.mulesoft.org/schema/mule/azure-cosmos-db-connector-mule-4/current/mule-azure-cosmos-db-connector-mule-4.xsd">
<configuration-properties file="mule-app.properties"/>
<http:listener-config name="HTTP_Listener_config">
<http:listener-connection host="0.0.0.0" port="8081"/>
</http:listener-config>
<azure-cosmos-db-connector-mule-4:key-token-config name="Cosmos_Db_Connector_Config">
<azure-cosmos-db-connector-mule-4:key-token-auth-connection key="${config.myKey}"
version="${config.version}"
baseUri="${config.baseUri}"/>
</azure-cosmos-db-connector-mule-4:key-token-config>
<azure-cosmos-db-connector-mule-4:resource-token-config name="Cosmos_Db_Connector_Config_Resource_Token">
<azure-cosmos-db-connector-mule-4:resource-token-auth-connection resourceToken="#[vars.resourceToken]"
version="${config.version}"
baseUri="${config.baseUri}"/>
</azure-cosmos-db-connector-mule-4:resource-token-config>
<flow name="get-document-flow">
<http:listener config-ref="HTTP_Listener_config" path="/get-document"/>
<azure-cosmos-db-connector-mule-4:get-document config-ref="Cosmos_Db_Connector_Config"
dbIdUriParam="${config.database}"
collIdUriParam="${config.collection}"
xMsDocumentdbPartitionkeyHeader="#[write(['Mule_CosmosDB_DemoApp_DocumentId'], 'application/json')]"
docIdUriParam="Mule_CosmosDB_DemoApp_DocumentId"
ifNoneMatchHeader="noneMatch"
xMsConsistencyLevelHeader="SESSION">
</azure-cosmos-db-connector-mule-4:get-document>
<ee:transform>
<ee:message>
<ee:set-payload><![CDATA[%dw 2.0
output application/json
---
payload]]></ee:set-payload>
</ee:message>
</ee:transform>
<logger level="INFO" message="#[payload]"/>
</flow>
</mule>
Verify that your connector is configured.
Save the project.
From a web browser, test the application by entering http://localhost:8081/get-document.
This Mule flow replaces an existing document with a new document that contains the specified content.
This example uses the following operations:
HTTP Listener
Accepts data from HTTP requests
Replace Document
Replaces the entire content of a document
Transform Message
Outputs the results of the Replace Document operation in JSON format
Logger
Shows the HTTP response from the Replace Document operation
Paste this code into the Studio XML editor to quickly load the flow for this example into your Mule app:
<?xml version="1.0" encoding="UTF-8"?>
<mule
xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
xmlns:azure-cosmos-db-connector-mule-4="http://www.mulesoft.org/schema/mule/azure-cosmos-db-connector-mule-4"
xmlns:ee="http://www.mulesoft.org/schema/mule/ee/core" xmlns:http="http://www.mulesoft.org/schema/mule/http"
xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
http://www.mulesoft.org/schema/mule/ee/core http://www.mulesoft.org/schema/mule/ee/core/current/mule-ee.xsd
http://www.mulesoft.org/schema/mule/azure-cosmos-db-connector-mule-4 http://www.mulesoft.org/schema/mule/azure-cosmos-db-connector-mule-4/current/mule-azure-cosmos-db-connector-mule-4.xsd">
<configuration-properties file="mule-app.properties"/>
<http:listener-config name="HTTP_Listener_config">
<http:listener-connection host="0.0.0.0" port="8081"/>
</http:listener-config>
<azure-cosmos-db-connector-mule-4:key-token-config name="Cosmos_Db_Connector_Config">
<azure-cosmos-db-connector-mule-4:key-token-auth-connection key="${config.myKey}"
version="${config.version}"
baseUri="${config.baseUri}"/>
</azure-cosmos-db-connector-mule-4:key-token-config>
<azure-cosmos-db-connector-mule-4:resource-token-config name="Cosmos_Db_Connector_Config_Resource_Token">
<azure-cosmos-db-connector-mule-4:resource-token-auth-connection resourceToken="#[vars.resourceToken]"
version="${config.version}"
baseUri="${config.baseUri}"/>
</azure-cosmos-db-connector-mule-4:resource-token-config>
<flow name="replace-document-flow">
<http:listener config-ref="HTTP_Listener_config" path="/replace-document"/>
<azure-cosmos-db-connector-mule-4:replace-document config-ref="Cosmos_Db_Connector_Config"
dbIdUriParam="${config.database}"
collIdUriParam="${config.collection}"
xMsDocumentdbPartitionkeyHeader="#[write(['Mule_CosmosDB_DemoApp_DocumentId'], 'application/json')]"
docIdUriParam="Mule_CosmosDB_DemoApp_DocumentId"
xMsIndexingDirectiveHeader="INCLUDE">
<azure-cosmos-db-connector-mule-4:replace-document-body>
<![CDATA[#[%dw 2.0
output application/json
---
{
"id" : "Mule_CosmosDB_DemoApp_DocumentId",
"firstName" : "Jane",
"lastName" : "Doe"
}]]]></azure-cosmos-db-connector-mule-4:replace-document-body>
</azure-cosmos-db-connector-mule-4:replace-document>
<ee:transform>
<ee:message>
<ee:set-payload><![CDATA[%dw 2.0
output application/json
---
payload]]></ee:set-payload>
</ee:message>
</ee:transform>
<logger level="INFO" message="#[payload]"/>
</flow>
</mule>
Verify that your connector is configured.
Save the project.
From a web browser, test the application by entering http://localhost:8081/replace-document.
This Mule flow obtains a list of existing documents based on the specified query, with pagination support handled internally by the connector.
This example uses the following operations:
HTTP Listener
Accepts data from HTTP requests
List Documents
Returns a list of documents under the collection
Transform Message
Outputs the results of the List Documents operation in JSON format
Logger
Shows the HTTP response from the List Documents operation
Paste this code into the Studio XML editor to quickly load the flow for this example into your Mule app:
<?xml version="1.0" encoding="UTF-8"?>
<mule
xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
xmlns:azure-cosmos-db-connector-mule-4="http://www.mulesoft.org/schema/mule/azure-cosmos-db-connector-mule-4"
xmlns:ee="http://www.mulesoft.org/schema/mule/ee/core" xmlns:http="http://www.mulesoft.org/schema/mule/http"
xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
http://www.mulesoft.org/schema/mule/ee/core http://www.mulesoft.org/schema/mule/ee/core/current/mule-ee.xsd
http://www.mulesoft.org/schema/mule/azure-cosmos-db-connector-mule-4 http://www.mulesoft.org/schema/mule/azure-cosmos-db-connector-mule-4/current/mule-azure-cosmos-db-connector-mule-4.xsd">
<configuration-properties file="mule-app.properties"/>
<http:listener-config name="HTTP_Listener_config">
<http:listener-connection host="0.0.0.0" port="8081"/>
</http:listener-config>
<azure-cosmos-db-connector-mule-4:key-token-config name="Cosmos_Db_Connector_Config">
<azure-cosmos-db-connector-mule-4:key-token-auth-connection key="${config.myKey}"
version="${config.version}"
baseUri="${config.baseUri}"/>
</azure-cosmos-db-connector-mule-4:key-token-config>
<azure-cosmos-db-connector-mule-4:resource-token-config name="Cosmos_Db_Connector_Config_Resource_Token">
<azure-cosmos-db-connector-mule-4:resource-token-auth-connection resourceToken="#[vars.resourceToken]"
version="${config.version}"
baseUri="${config.baseUri}"/>
</azure-cosmos-db-connector-mule-4:resource-token-config>
<flow name="list-documents-flow">
<http:listener config-ref="HTTP_Listener_config" path="/list-documents"/>
<azure-cosmos-db-connector-mule-4:list-documents config-ref="Cosmos_Db_Connector_Config"
dbIdUriParam="${config.database}"
collIdUriParam="${config.collection}"
xMsConsistencyLevelHeader="SESSION"
ifNoneMatchHeader="noneMatch">
</azure-cosmos-db-connector-mule-4:list-documents>
<ee:transform>
<ee:message>
<ee:set-payload><![CDATA[%dw 2.0
output application/json
---
payload]]></ee:set-payload>
</ee:message>
</ee:transform>
<logger level="INFO" message="#[payload]"/>
</flow>
</mule>
Verify that your connector is configured.
Save the project.
From a web browser, test the application by entering http://localhost:8081/list-documents.
This Mule flow obtains a list of existing documents based on the specified query, with pagination support handled internally by the connector.
This example uses the following operations:
HTTP Listener
Accepts data from HTTP requests
Query Documents
Queries documents
Transform Message
Outputs the results of the Query Documents operation in JSON format
Logger
Shows the HTTP response from the Query Documents operation
Paste this code into the Studio XML editor to quickly load the flow for this example into your Mule app:
<?xml version="1.0" encoding="UTF-8"?>
<mule
xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
xmlns:azure-cosmos-db-connector-mule-4="http://www.mulesoft.org/schema/mule/azure-cosmos-db-connector-mule-4"
xmlns:ee="http://www.mulesoft.org/schema/mule/ee/core" xmlns:http="http://www.mulesoft.org/schema/mule/http"
xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
http://www.mulesoft.org/schema/mule/ee/core http://www.mulesoft.org/schema/mule/ee/core/current/mule-ee.xsd
http://www.mulesoft.org/schema/mule/azure-cosmos-db-connector-mule-4 http://www.mulesoft.org/schema/mule/azure-cosmos-db-connector-mule-4/current/mule-azure-cosmos-db-connector-mule-4.xsd">
<configuration-properties file="mule-app.properties"/>
<http:listener-config name="HTTP_Listener_config">
<http:listener-connection host="0.0.0.0" port="8081"/>
</http:listener-config>
<azure-cosmos-db-connector-mule-4:key-token-config name="Cosmos_Db_Connector_Config">
<azure-cosmos-db-connector-mule-4:key-token-auth-connection key="${config.myKey}"
version="${config.version}"
baseUri="${config.baseUri}"/>
</azure-cosmos-db-connector-mule-4:key-token-config>
<azure-cosmos-db-connector-mule-4:resource-token-config name="Cosmos_Db_Connector_Config_Resource_Token">
<azure-cosmos-db-connector-mule-4:resource-token-auth-connection resourceToken="#[vars.resourceToken]"
version="${config.version}"
baseUri="${config.baseUri}"/>
</azure-cosmos-db-connector-mule-4:resource-token-config>
<flow name="query-documents-flow">
<http:listener config-ref="HTTP_Listener_config" path="/query-documents"/>
<azure-cosmos-db-connector-mule-4:query-documents config-ref="Cosmos_Db_Connector_Config"
dbIdUriParam="${config.database}"
collIdUriParam="${config.collection}"
xMsConsistencyLevelHeader="SESSION"
xMsDocumentdbQueryEnablecrosspartitionHeader="true">
<azure-cosmos-db-connector-mule-4:query-documents-body>
<![CDATA[#[%dw 2.0
output application/json
---
{
"query": "SELECT * FROM Families f WHERE f.id = @id AND f.Address.City = @city",
"parameters": [
{
"name": "@id",
"value": "AndersenFamily"
},
{
"name": "@city",
"value": "Seattle"
}
]
}]]]></azure-cosmos-db-connector-mule-4:query-documents-body>
</azure-cosmos-db-connector-mule-4:query-documents>
<ee:transform>
<ee:message>
<ee:set-payload><![CDATA[%dw 2.0
output application/json
---
payload]]></ee:set-payload>
</ee:message>
</ee:transform>
<logger level="INFO" message="#[payload]"/>
</flow>
</mule>
Verify that your connector is configured.
Save the project.
From a web browser, test the application by entering http://localhost:8081/query-documents.
This Mule flow deletes an existing document.
This example uses the following operations:
HTTP Listener
Accepts data from HTTP requests
Delete Document
Deletes an existing document from a collection
Logger
Shows the HTTP response from the Delete Document operation
Paste this code into the Studio XML editor to quickly load the flow for this example into your Mule app:
<?xml version="1.0" encoding="UTF-8"?>
<mule
xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
xmlns:azure-cosmos-db-connector-mule-4="http://www.mulesoft.org/schema/mule/azure-cosmos-db-connector-mule-4"
xmlns:ee="http://www.mulesoft.org/schema/mule/ee/core" xmlns:http="http://www.mulesoft.org/schema/mule/http"
xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
http://www.mulesoft.org/schema/mule/ee/core http://www.mulesoft.org/schema/mule/ee/core/current/mule-ee.xsd
http://www.mulesoft.org/schema/mule/azure-cosmos-db-connector-mule-4 http://www.mulesoft.org/schema/mule/azure-cosmos-db-connector-mule-4/current/mule-azure-cosmos-db-connector-mule-4.xsd">
<configuration-properties file="mule-app.properties"/>
<http:listener-config name="HTTP_Listener_config">
<http:listener-connection host="0.0.0.0" port="8081"/>
</http:listener-config>
<azure-cosmos-db-connector-mule-4:key-token-config name="Cosmos_Db_Connector_Config">
<azure-cosmos-db-connector-mule-4:key-token-auth-connection key="${config.myKey}"
version="${config.version}"
baseUri="${config.baseUri}"/>
</azure-cosmos-db-connector-mule-4:key-token-config>
<azure-cosmos-db-connector-mule-4:resource-token-config name="Cosmos_Db_Connector_Config_Resource_Token">
<azure-cosmos-db-connector-mule-4:resource-token-auth-connection resourceToken="#[vars.resourceToken]"
version="${config.version}"
baseUri="${config.baseUri}"/>
</azure-cosmos-db-connector-mule-4:resource-token-config>
<flow name="delete-document-flow">
<http:listener config-ref="HTTP_Listener_config" path="/delete-document"/>
<azure-cosmos-db-connector-mule-4:delete-document config-ref="Cosmos_Db_Connector_Config"
dbIdUriParam="${config.database}"
collIdUriParam="${config.collection}"
xMsDocumentdbPartitionkeyHeader="#[write(['Mule_CosmosDB_DemoApp_DocumentId'], 'application/json')]"
docIdUriParam="Mule_CosmosDB_DemoApp_DocumentId">
</azure-cosmos-db-connector-mule-4:delete-document>
<logger level="INFO" message="#[payload]"/>
</flow>
</mule>
Verify that your connector is configured.
Save the project.
From a web browser, test the application by entering http://localhost:8081/delete-document.
This Mule flow creates a stored procedure with the specified content.
This example uses the following operations:
HTTP Listener
Accepts data from HTTP requests
Transform Message
Transforms the HTTP input
Create Stored Procedure
Creates a new stored procedure in a collection
Transform Message
Outputs the results of the Create Stored Procedure operation in JSON format
Logger
Shows the HTTP response from the Create Stored Procedure operation
Paste this code into the Studio XML editor to quickly load the flow for this example into your Mule app:
<?xml version="1.0" encoding="UTF-8"?>
<mule
xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
xmlns:azure-cosmos-db-connector-mule-4="http://www.mulesoft.org/schema/mule/azure-cosmos-db-connector-mule-4"
xmlns:ee="http://www.mulesoft.org/schema/mule/ee/core" xmlns:http="http://www.mulesoft.org/schema/mule/http"
xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
http://www.mulesoft.org/schema/mule/ee/core http://www.mulesoft.org/schema/mule/ee/core/current/mule-ee.xsd
http://www.mulesoft.org/schema/mule/azure-cosmos-db-connector-mule-4 http://www.mulesoft.org/schema/mule/azure-cosmos-db-connector-mule-4/current/mule-azure-cosmos-db-connector-mule-4.xsd">
<configuration-properties file="mule-app.properties"/>
<http:listener-config name="HTTP_Listener_config">
<http:listener-connection host="0.0.0.0" port="8081"/>
</http:listener-config>
<azure-cosmos-db-connector-mule-4:key-token-config name="Cosmos_Db_Connector_Config">
<azure-cosmos-db-connector-mule-4:key-token-auth-connection key="${config.myKey}"
version="${config.version}"
baseUri="${config.baseUri}"/>
</azure-cosmos-db-connector-mule-4:key-token-config>
<azure-cosmos-db-connector-mule-4:resource-token-config name="Cosmos_Db_Connector_Config_Resource_Token">
<azure-cosmos-db-connector-mule-4:resource-token-auth-connection resourceToken="#[vars.resourceToken]"
version="${config.version}"
baseUri="${config.baseUri}"/>
</azure-cosmos-db-connector-mule-4:resource-token-config>
<flow name="create-stored-procedure-flow">
<http:listener config-ref="HTTP_Listener_config" path="/create-stored-procedure"/>
<ee:transform>
<ee:message>
<ee:set-payload>
<![CDATA[%dw 2.0
output application/json
---
{
"body": "function () {\r\n var context = getContext();\r\n var response = context.getResponse();\r\n\r\n response.setBody(\"Hello, World\");\r\n}",
"id": "Mule_CosmosDB_DemoApp_StoredProcedureId"
} ]]>
</ee:set-payload>
</ee:message>
</ee:transform>
<azure-cosmos-db-connector-mule-4:create-stored-procedure config-ref="Cosmos_Db_Connector_Config"
dbIdUriParam="${config.database}"
collIdUriParam="${config.collection}">
</azure-cosmos-db-connector-mule-4:create-stored-procedure>
<ee:transform>
<ee:message>
<ee:set-payload><![CDATA[%dw 2.0
output application/json
---
payload]]></ee:set-payload>
</ee:message>
</ee:transform>
<logger level="INFO" message="#[payload]"/>
</flow>
</mule>
Verify that your connector is configured.
Save the project.
From a web browser, test the application by entering http://localhost:8081/create-stored-procedure.
This Mule flow executes an existing stored procedure.
This example uses the following operations:
HTTP Listener
Accepts data from HTTP requests
Transform Message
Transforms the HTTP input
Execute Stored Procedure
Executes a stored procedure by performing a POST on a stored procedure resource
Transform Message
Outputs the results of the Execute Stored Procedure operation in JSON format
Logger
Shows the HTTP response from the Execute Stored Procedure operation
Paste this code into the Studio XML editor to quickly load the flow for this example into your Mule app:
<?xml version="1.0" encoding="UTF-8"?>
<mule
xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
xmlns:azure-cosmos-db-connector-mule-4="http://www.mulesoft.org/schema/mule/azure-cosmos-db-connector-mule-4"
xmlns:ee="http://www.mulesoft.org/schema/mule/ee/core" xmlns:http="http://www.mulesoft.org/schema/mule/http"
xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
http://www.mulesoft.org/schema/mule/ee/core http://www.mulesoft.org/schema/mule/ee/core/current/mule-ee.xsd
http://www.mulesoft.org/schema/mule/azure-cosmos-db-connector-mule-4 http://www.mulesoft.org/schema/mule/azure-cosmos-db-connector-mule-4/current/mule-azure-cosmos-db-connector-mule-4.xsd">
<configuration-properties file="mule-app.properties"/>
<http:listener-config name="HTTP_Listener_config">
<http:listener-connection host="0.0.0.0" port="8081"/>
</http:listener-config>
<azure-cosmos-db-connector-mule-4:key-token-config name="Cosmos_Db_Connector_Config">
<azure-cosmos-db-connector-mule-4:key-token-auth-connection key="${config.myKey}"
version="${config.version}"
baseUri="${config.baseUri}"/>
</azure-cosmos-db-connector-mule-4:key-token-config>
<azure-cosmos-db-connector-mule-4:resource-token-config name="Cosmos_Db_Connector_Config_Resource_Token">
<azure-cosmos-db-connector-mule-4:resource-token-auth-connection resourceToken="#[vars.resourceToken]"
version="${config.version}"
baseUri="${config.baseUri}"/>
</azure-cosmos-db-connector-mule-4:resource-token-config>
<flow name="execute-stored-procedure-flow">
<http:listener config-ref="HTTP_Listener_config" path="/execute-stored-procedure"/>
<ee:transform>
<ee:message>
<ee:set-payload><![CDATA[%dw 2.0
output application/json
---
["World"]
]]>
</ee:set-payload>
</ee:message>
</ee:transform>
<azure-cosmos-db-connector-mule-4:execute-stored-procedure config-ref="Cosmos_Db_Connector_Config"
dbIdUriParam="${config.database}"
collIdUriParam="${config.collection}"
sprocIdUriParam="Mule_CosmosDB_DemoApp_StoredProcedureId">
</azure-cosmos-db-connector-mule-4:execute-stored-procedure>
<ee:transform>
<ee:message>
<ee:set-payload><![CDATA[%dw 2.0
output application/json
---
payload]]></ee:set-payload>
</ee:message>
</ee:transform>
<logger level="INFO" message="#[payload]"/>
</flow>
</mule>
Verify that your connector is configured.
Save the project.
From a web browser, test the application by entering http://localhost:8081/execute-stored-procedure.
This Mule flow replaces an existing stored procedure.
This example uses the following operations:
HTTP Listener
Accepts data from HTTP requests
Transform Message
Transforms the HTTP input
Replace Stored Procedure
Replaces the entire stored procedure resource
Transform Message
Outputs the results of the Replace Stored Procedure operation in JSON format
Logger
Shows the HTTP response from the Replace Stored Procedure operation
Paste this code into the Studio XML editor to quickly load the flow for this example into your Mule app:
<?xml version="1.0" encoding="UTF-8"?>
<mule
xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
xmlns:azure-cosmos-db-connector-mule-4="http://www.mulesoft.org/schema/mule/azure-cosmos-db-connector-mule-4"
xmlns:ee="http://www.mulesoft.org/schema/mule/ee/core" xmlns:http="http://www.mulesoft.org/schema/mule/http"
xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
http://www.mulesoft.org/schema/mule/ee/core http://www.mulesoft.org/schema/mule/ee/core/current/mule-ee.xsd
http://www.mulesoft.org/schema/mule/azure-cosmos-db-connector-mule-4 http://www.mulesoft.org/schema/mule/azure-cosmos-db-connector-mule-4/current/mule-azure-cosmos-db-connector-mule-4.xsd">
<configuration-properties file="mule-app.properties"/>
<http:listener-config name="HTTP_Listener_config">
<http:listener-connection host="0.0.0.0" port="8081"/>
</http:listener-config>
<azure-cosmos-db-connector-mule-4:key-token-config name="Cosmos_Db_Connector_Config">
<azure-cosmos-db-connector-mule-4:key-token-auth-connection key="${config.myKey}"
version="${config.version}"
baseUri="${config.baseUri}"/>
</azure-cosmos-db-connector-mule-4:key-token-config>
<azure-cosmos-db-connector-mule-4:resource-token-config name="Cosmos_Db_Connector_Config_Resource_Token">
<azure-cosmos-db-connector-mule-4:resource-token-auth-connection resourceToken="#[vars.resourceToken]"
version="${config.version}"
baseUri="${config.baseUri}"/>
</azure-cosmos-db-connector-mule-4:resource-token-config>
<flow name="replace-stored-procedure-flow">
<http:listener config-ref="HTTP_Listener_config" path="/replace-stored-procedure"/>
<ee:transform>
<ee:message>
<ee:set-payload><![CDATA[%dw 2.0
output application/json
---
{
"body": "function () {\r\n var context = getContext();\r\n var response = context.getResponse();\r\n\r\n response.setBody(\"Goodbye, World\");\r\n}",
"id": "Mule_CosmosDB_DemoApp_StoredProcedureId"
} ]]>
</ee:set-payload>
</ee:message>
</ee:transform>
<azure-cosmos-db-connector-mule-4:replace-stored-procedure config-ref="Cosmos_Db_Connector_Config"
dbIdUriParam="${config.database}"
collIdUriParam="${config.collection}"
sprocIdUriParam="Mule_CosmosDB_DemoApp_StoredProcedureId">
</azure-cosmos-db-connector-mule-4:replace-stored-procedure>
<ee:transform>
<ee:message>
<ee:set-payload><![CDATA[%dw 2.0
output application/json
---
payload]]></ee:set-payload>
</ee:message>
</ee:transform>
<logger level="INFO" message="#[payload]"/>
</flow>
</mule>
Verify that your connector is configured.
Save the project.
From a web browser, test the application by entering http://localhost:8081/replace-stored-procedure.
This Mule flow obtains a list of existing stored procedures.
This example uses the following operations:
HTTP Listener
Accepts data from HTTP requests
List Stored Procedures
Returns a list of the stored procedures in the collection
Transform Message
Outputs the results of the List Stored Procedures operation in JSON format
Logger
Shows the HTTP response from the List Stored Procedures operation
Paste this code into the Studio XML editor to quickly load the flow for this example into your Mule app:
<?xml version="1.0" encoding="UTF-8"?>
<mule
xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
xmlns:azure-cosmos-db-connector-mule-4="http://www.mulesoft.org/schema/mule/azure-cosmos-db-connector-mule-4"
xmlns:ee="http://www.mulesoft.org/schema/mule/ee/core" xmlns:http="http://www.mulesoft.org/schema/mule/http"
xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
http://www.mulesoft.org/schema/mule/ee/core http://www.mulesoft.org/schema/mule/ee/core/current/mule-ee.xsd
http://www.mulesoft.org/schema/mule/azure-cosmos-db-connector-mule-4 http://www.mulesoft.org/schema/mule/azure-cosmos-db-connector-mule-4/current/mule-azure-cosmos-db-connector-mule-4.xsd">
<configuration-properties file="mule-app.properties"/>
<http:listener-config name="HTTP_Listener_config">
<http:listener-connection host="0.0.0.0" port="8081"/>
</http:listener-config>
<azure-cosmos-db-connector-mule-4:key-token-config name="Cosmos_Db_Connector_Config">
<azure-cosmos-db-connector-mule-4:key-token-auth-connection key="${config.myKey}"
version="${config.version}"
baseUri="${config.baseUri}"/>
</azure-cosmos-db-connector-mule-4:key-token-config>
<azure-cosmos-db-connector-mule-4:resource-token-config name="Cosmos_Db_Connector_Config_Resource_Token">
<azure-cosmos-db-connector-mule-4:resource-token-auth-connection resourceToken="#[vars.resourceToken]"
version="${config.version}"
baseUri="${config.baseUri}"/>
</azure-cosmos-db-connector-mule-4:resource-token-config>
<flow name="list-stored-procedures-flow">
<http:listener config-ref="HTTP_Listener_config" path="/list-stored-procedures"/>
<azure-cosmos-db-connector-mule-4:list-stored-procedures config-ref="Cosmos_Db_Connector_Config"
dbIdUriParam="${config.database}"
collIdUriParam="${config.collection}">
</azure-cosmos-db-connector-mule-4:list-stored-procedures>
<ee:transform>
<ee:message>
<ee:set-payload><![CDATA[%dw 2.0
output application/json
---
payload]]></ee:set-payload>
</ee:message>
</ee:transform>
<logger level="INFO" message="#[payload]"/>
</flow>
</mule>
Verify that your connector is configured.
Save the project.
From a web browser, test the application by entering http://localhost:8081/list-stored-procedures.
This Mule flow deletes an existing stored procedure.
This example uses the following operations:
HTTP Listener
Accepts data from HTTP requests
Delete Stored Procedure
Deletes an existing stored procedure from a collection
Logger
Shows the HTTP response from the Delete Stored Procedure operation
Paste this code into the Studio XML editor to quickly load the flow for this example into your Mule app:
<?xml version="1.0" encoding="UTF-8"?>
<mule
xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
xmlns:azure-cosmos-db-connector-mule-4="http://www.mulesoft.org/schema/mule/azure-cosmos-db-connector-mule-4"
xmlns:ee="http://www.mulesoft.org/schema/mule/ee/core" xmlns:http="http://www.mulesoft.org/schema/mule/http"
xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
http://www.mulesoft.org/schema/mule/ee/core http://www.mulesoft.org/schema/mule/ee/core/current/mule-ee.xsd
http://www.mulesoft.org/schema/mule/azure-cosmos-db-connector-mule-4 http://www.mulesoft.org/schema/mule/azure-cosmos-db-connector-mule-4/current/mule-azure-cosmos-db-connector-mule-4.xsd">
<configuration-properties file="mule-app.properties"/>
<http:listener-config name="HTTP_Listener_config">
<http:listener-connection host="0.0.0.0" port="8081"/>
</http:listener-config>
<azure-cosmos-db-connector-mule-4:key-token-config name="Cosmos_Db_Connector_Config">
<azure-cosmos-db-connector-mule-4:key-token-auth-connection key="${config.myKey}"
version="${config.version}"
baseUri="${config.baseUri}"/>
</azure-cosmos-db-connector-mule-4:key-token-config>
<azure-cosmos-db-connector-mule-4:resource-token-config name="Cosmos_Db_Connector_Config_Resource_Token">
<azure-cosmos-db-connector-mule-4:resource-token-auth-connection resourceToken="#[vars.resourceToken]"
version="${config.version}"
baseUri="${config.baseUri}"/>
</azure-cosmos-db-connector-mule-4:resource-token-config>
<flow name="delete-stored-procedure-flow">
<http:listener config-ref="HTTP_Listener_config" path="/delete-stored-procedure"/>
<azure-cosmos-db-connector-mule-4:delete-stored-procedure config-ref="Cosmos_Db_Connector_Config"
dbIdUriParam="${config.database}"
collIdUriParam="${config.collection}"
sprocIdUriParam="Mule_CosmosDB_DemoApp_StoredProcedureId">
</azure-cosmos-db-connector-mule-4:delete-stored-procedure>
<logger level="INFO" message="#[payload]"/>
</flow>
</mule>
Verify that your connector is configured.
Save the project.
From a web browser, test the application by entering http://localhost:8081/delete-stored-procedure.
This Mule flow creates a user permission to access a resource.
This example uses the following operations:
HTTP Listener
Accepts data from HTTP requests
Create Permission
Creates a new permission in a database
Transform Message
Outputs the results of the Create Permission operation in JSON format
Logger
Shows the HTTP response from the Create Permission operation
Paste this code into the Studio XML editor to quickly load the flow for this example into your Mule app:
<?xml version="1.0" encoding="UTF-8"?>
<mule
xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
xmlns:azure-cosmos-db-connector-mule-4="http://www.mulesoft.org/schema/mule/azure-cosmos-db-connector-mule-4"
xmlns:ee="http://www.mulesoft.org/schema/mule/ee/core" xmlns:http="http://www.mulesoft.org/schema/mule/http"
xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
http://www.mulesoft.org/schema/mule/ee/core http://www.mulesoft.org/schema/mule/ee/core/current/mule-ee.xsd
http://www.mulesoft.org/schema/mule/azure-cosmos-db-connector-mule-4 http://www.mulesoft.org/schema/mule/azure-cosmos-db-connector-mule-4/current/mule-azure-cosmos-db-connector-mule-4.xsd">
<configuration-properties file="mule-app.properties"/>
<http:listener-config name="HTTP_Listener_config">
<http:listener-connection host="0.0.0.0" port="8081"/>
</http:listener-config>
<azure-cosmos-db-connector-mule-4:key-token-config name="Cosmos_Db_Connector_Config">
<azure-cosmos-db-connector-mule-4:key-token-auth-connection key="${config.myKey}"
version="${config.version}"
baseUri="${config.baseUri}"/>
</azure-cosmos-db-connector-mule-4:key-token-config>
<azure-cosmos-db-connector-mule-4:resource-token-config name="Cosmos_Db_Connector_Config_Resource_Token">
<azure-cosmos-db-connector-mule-4:resource-token-auth-connection resourceToken="#[vars.resourceToken]"
version="${config.version}"
baseUri="${config.baseUri}"/>
</azure-cosmos-db-connector-mule-4:resource-token-config>
<flow name="create-permission-flow">
<http:listener config-ref="HTTP_Listener_config" path="/create-permission"/>
<azure-cosmos-db-connector-mule-4:create-permission config-ref="Cosmos_Db_Connector_Config"
dbIdUriParam="${config.database}"
username="${config.username}"
xMsDocumentdbExpirySeconds="18000">
<azure-cosmos-db-connector-mule-4:create-permission-body><![CDATA[#[%dw 2.0
output application/json
---
{
"id": "Mule_CosmosDB_DemoApp_ResourceToken_PermissionId",
"permissionMode": "All",
"resource": "dbs/" ++ "${config.database}" ++ "/colls/" ++ "${config.collection}"
}]]]></azure-cosmos-db-connector-mule-4:create-permission-body>
</azure-cosmos-db-connector-mule-4:create-permission>
<ee:transform>
<ee:message>
<ee:set-payload><![CDATA[%dw 2.0
output application/json
---
payload]]></ee:set-payload>
</ee:message>
</ee:transform>
<logger level="INFO" message="#[payload]"/>
</flow>
</mule>
Verify that your connector is configured.
Save the project.
From a web browser, test the application by entering http://localhost:8081/create-permission.
This Mule flow retrieves an existing permission.
This example uses the following operations:
HTTP Listener
Accepts data from HTTP requests
Get Permission
Gets a permission from a database
Transform Message
Outputs the results of the Get Permission operation in JSON format
Logger
Shows the HTTP response from the Get Permission operation
Paste this code into the Studio XML editor to quickly load the flow for this example into your Mule app:
<?xml version="1.0" encoding="UTF-8"?>
<mule
xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
xmlns:azure-cosmos-db-connector-mule-4="http://www.mulesoft.org/schema/mule/azure-cosmos-db-connector-mule-4"
xmlns:ee="http://www.mulesoft.org/schema/mule/ee/core" xmlns:http="http://www.mulesoft.org/schema/mule/http"
xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
http://www.mulesoft.org/schema/mule/ee/core http://www.mulesoft.org/schema/mule/ee/core/current/mule-ee.xsd
http://www.mulesoft.org/schema/mule/azure-cosmos-db-connector-mule-4 http://www.mulesoft.org/schema/mule/azure-cosmos-db-connector-mule-4/current/mule-azure-cosmos-db-connector-mule-4.xsd">
<configuration-properties file="mule-app.properties"/>
<http:listener-config name="HTTP_Listener_config">
<http:listener-connection host="0.0.0.0" port="8081"/>
</http:listener-config>
<azure-cosmos-db-connector-mule-4:key-token-config name="Cosmos_Db_Connector_Config">
<azure-cosmos-db-connector-mule-4:key-token-auth-connection key="${config.myKey}"
version="${config.version}"
baseUri="${config.baseUri}"/>
</azure-cosmos-db-connector-mule-4:key-token-config>
<azure-cosmos-db-connector-mule-4:resource-token-config name="Cosmos_Db_Connector_Config_Resource_Token">
<azure-cosmos-db-connector-mule-4:resource-token-auth-connection resourceToken="#[vars.resourceToken]"
version="${config.version}"
baseUri="${config.baseUri}"/>
</azure-cosmos-db-connector-mule-4:resource-token-config>
<flow name="get-permission-flow">
<http:listener config-ref="HTTP_Listener_config" path="/get-permission"/>
<azure-cosmos-db-connector-mule-4:get-permission config-ref="Cosmos_Db_Connector_Config"
dbIdUriParam="${config.database}"
username="${config.username}"
permissionId="Mule_CosmosDB_DemoApp_ResourceToken_PermissionId"
xMsDocumentdbExpirySeconds="1800">
</azure-cosmos-db-connector-mule-4:get-permission>
<ee:transform>
<ee:message>
<ee:set-payload><![CDATA[%dw 2.0
output application/json
---
payload]]></ee:set-payload>
</ee:message>
</ee:transform>
<logger level="INFO" message="#[payload]"/>
</flow>
</mule>
Verify that your connector is configured.
Save the project.
From a web browser, test the application by entering http://localhost:8081/get-permission.
This Mule flow replaces an existing permission to access a resource for a user with another permission.
This example uses the following operations:
HTTP Listener
Accepts data from HTTP requests
Replace Permission
Replaces a permission from a database
Transform Message
Outputs the results of the Replace Permission operation in JSON format
Logger
Shows the HTTP response from the Replace Permission operation
Paste this code into the Studio XML editor to quickly load the flow for this example into your Mule app:
<?xml version="1.0" encoding="UTF-8"?>
<mule
xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
xmlns:azure-cosmos-db-connector-mule-4="http://www.mulesoft.org/schema/mule/azure-cosmos-db-connector-mule-4"
xmlns:ee="http://www.mulesoft.org/schema/mule/ee/core" xmlns:http="http://www.mulesoft.org/schema/mule/http"
xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
http://www.mulesoft.org/schema/mule/ee/core http://www.mulesoft.org/schema/mule/ee/core/current/mule-ee.xsd
http://www.mulesoft.org/schema/mule/azure-cosmos-db-connector-mule-4 http://www.mulesoft.org/schema/mule/azure-cosmos-db-connector-mule-4/current/mule-azure-cosmos-db-connector-mule-4.xsd">
<configuration-properties file="mule-app.properties"/>
<http:listener-config name="HTTP_Listener_config">
<http:listener-connection host="0.0.0.0" port="8081"/>
</http:listener-config>
<azure-cosmos-db-connector-mule-4:key-token-config name="Cosmos_Db_Connector_Config">
<azure-cosmos-db-connector-mule-4:key-token-auth-connection key="${config.myKey}"
version="${config.version}"
baseUri="${config.baseUri}"/>
</azure-cosmos-db-connector-mule-4:key-token-config>
<azure-cosmos-db-connector-mule-4:resource-token-config name="Cosmos_Db_Connector_Config_Resource_Token">
<azure-cosmos-db-connector-mule-4:resource-token-auth-connection resourceToken="#[vars.resourceToken]"
version="${config.version}"
baseUri="${config.baseUri}"/>
</azure-cosmos-db-connector-mule-4:resource-token-config>
<flow name="replace-permission-flow">
<http:listener config-ref="HTTP_Listener_config" path="/replace-permission"/>
<azure-cosmos-db-connector-mule-4:replace-permission config-ref="Cosmos_Db_Connector_Config"
dbIdUriParam="${config.database}"
username="${config.username}"
permissionId="Mule_CosmosDB_DemoApp_ResourceToken_PermissionId"
xMsDocumentdbExpirySeconds="1800">
<azure-cosmos-db-connector-mule-4:replace-permission-body><![CDATA[#[%dw 2.0
output application/json
---
{
"id": "Mule_CosmosDB_DemoApp_ResourceToken_PermissionId",
"permissionMode": "Read",
"resource": "dbs/" ++ "${config.database}" ++ "/colls/" ++ "${config.collection}"
}]]]></azure-cosmos-db-connector-mule-4:replace-permission-body>
</azure-cosmos-db-connector-mule-4:replace-permission>
<ee:transform>
<ee:message>
<ee:set-payload><![CDATA[%dw 2.0
output application/json
---
payload]]></ee:set-payload>
</ee:message>
</ee:transform>
<logger level="INFO" message="#[payload]"/>
</flow>
</mule>
Verify that your connector is configured.
Save the project.
From a web browser, test the application by entering http://localhost:8081/replace-permission.
This Mule flow obtains a list of existing permissions.
This example uses the following operations:
HTTP Listener
Accepts data from HTTP requests
List Permissions
Lists permissions of a user from a database
Transform Message
Outputs the results of the List Permissions operation in JSON format
Logger
Shows the HTTP response from the List Permissions operation
Paste this code into the Studio XML editor to quickly load the flow for this example into your Mule app:
<?xml version="1.0" encoding="UTF-8"?>
<mule
xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
xmlns:azure-cosmos-db-connector-mule-4="http://www.mulesoft.org/schema/mule/azure-cosmos-db-connector-mule-4"
xmlns:ee="http://www.mulesoft.org/schema/mule/ee/core" xmlns:http="http://www.mulesoft.org/schema/mule/http"
xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
http://www.mulesoft.org/schema/mule/ee/core http://www.mulesoft.org/schema/mule/ee/core/current/mule-ee.xsd
http://www.mulesoft.org/schema/mule/azure-cosmos-db-connector-mule-4 http://www.mulesoft.org/schema/mule/azure-cosmos-db-connector-mule-4/current/mule-azure-cosmos-db-connector-mule-4.xsd">
<configuration-properties file="mule-app.properties"/>
<http:listener-config name="HTTP_Listener_config">
<http:listener-connection host="0.0.0.0" port="8081"/>
</http:listener-config>
<azure-cosmos-db-connector-mule-4:key-token-config name="Cosmos_Db_Connector_Config">
<azure-cosmos-db-connector-mule-4:key-token-auth-connection key="${config.myKey}"
version="${config.version}"
baseUri="${config.baseUri}"/>
</azure-cosmos-db-connector-mule-4:key-token-config>
<azure-cosmos-db-connector-mule-4:resource-token-config name="Cosmos_Db_Connector_Config_Resource_Token">
<azure-cosmos-db-connector-mule-4:resource-token-auth-connection resourceToken="#[vars.resourceToken]"
version="${config.version}"
baseUri="${config.baseUri}"/>
</azure-cosmos-db-connector-mule-4:resource-token-config>
<flow name="list-permissions-flow">
<http:listener config-ref="HTTP_Listener_config" path="/list-permissions"/>
<azure-cosmos-db-connector-mule-4:list-permissions config-ref="Cosmos_Db_Connector_Config"
dbIdUriParam="${config.database}"
username="${config.username}">
</azure-cosmos-db-connector-mule-4:list-permissions>
<ee:transform>
<ee:message>
<ee:set-payload><![CDATA[%dw 2.0
output application/json
---
payload]]></ee:set-payload>
</ee:message>
</ee:transform>
<logger level="INFO" message="#[payload]"/>
</flow>
</mule>
Verify that your connector is configured.
Save the project.
From a web browser, test the application by entering http://localhost:8081/list-permissions.
This Mule flow deletes an existing permission.
This example uses the following operations:
HTTP Listener
Accepts data from HTTP requests
Delete Permission
Deletes a permission from a database
Logger
Shows the HTTP response from the Delete Permission operation
Paste this code into the Studio XML editor to quickly load the flow for this example into your Mule app:
<?xml version="1.0" encoding="UTF-8"?>
<mule
xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
xmlns:azure-cosmos-db-connector-mule-4="http://www.mulesoft.org/schema/mule/azure-cosmos-db-connector-mule-4"
xmlns:ee="http://www.mulesoft.org/schema/mule/ee/core" xmlns:http="http://www.mulesoft.org/schema/mule/http"
xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
http://www.mulesoft.org/schema/mule/ee/core http://www.mulesoft.org/schema/mule/ee/core/current/mule-ee.xsd
http://www.mulesoft.org/schema/mule/azure-cosmos-db-connector-mule-4 http://www.mulesoft.org/schema/mule/azure-cosmos-db-connector-mule-4/current/mule-azure-cosmos-db-connector-mule-4.xsd">
<configuration-properties file="mule-app.properties"/>
<http:listener-config name="HTTP_Listener_config">
<http:listener-connection host="0.0.0.0" port="8081"/>
</http:listener-config>
<azure-cosmos-db-connector-mule-4:key-token-config name="Cosmos_Db_Connector_Config">
<azure-cosmos-db-connector-mule-4:key-token-auth-connection key="${config.myKey}"
version="${config.version}"
baseUri="${config.baseUri}"/>
</azure-cosmos-db-connector-mule-4:key-token-config>
<azure-cosmos-db-connector-mule-4:resource-token-config name="Cosmos_Db_Connector_Config_Resource_Token">
<azure-cosmos-db-connector-mule-4:resource-token-auth-connection resourceToken="#[vars.resourceToken]"
version="${config.version}"
baseUri="${config.baseUri}"/>
</azure-cosmos-db-connector-mule-4:resource-token-config>
<flow name="delete-permission-flow">
<http:listener config-ref="HTTP_Listener_config" path="/delete-permission"/>
<azure-cosmos-db-connector-mule-4:delete-permission config-ref="Cosmos_Db_Connector_Config"
dbIdUriParam="${config.database}"
username="${config.username}"
permissionId="Mule_CosmosDB_DemoApp_ResourceToken_PermissionId">
</azure-cosmos-db-connector-mule-4:delete-permission>
<logger level="INFO" message="#[payload]"/>
</flow>
</mule>
Verify that your connector is configured.
Save the project.
From a web browser, test the application by entering http://localhost:8081/delete-permission.
This Mule flow obtains a list of existing documents, with pagination support handled internally by the connector, and uses the short-lived tokens from the Resource Token authorization.
This example uses the following operations:
HTTP Listener
Accepts data from HTTP requests
Flow Reference
Obtains the resource token
List Documents
Returns a list of documents under the collection
Transform Message
Outputs the results of the List Documents operation in JSON format
Flow Reference
Clears the permissions
Logger
Shows the HTTP response from the List Documents operation
Paste this code into the Studio XML editor to quickly load the flow for this example into your Mule app:
<?xml version="1.0" encoding="UTF-8"?>
<mule
xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
xmlns:azure-cosmos-db-connector-mule-4="http://www.mulesoft.org/schema/mule/azure-cosmos-db-connector-mule-4"
xmlns:ee="http://www.mulesoft.org/schema/mule/ee/core" xmlns:http="http://www.mulesoft.org/schema/mule/http"
xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
http://www.mulesoft.org/schema/mule/ee/core http://www.mulesoft.org/schema/mule/ee/core/current/mule-ee.xsd
http://www.mulesoft.org/schema/mule/azure-cosmos-db-connector-mule-4 http://www.mulesoft.org/schema/mule/azure-cosmos-db-connector-mule-4/current/mule-azure-cosmos-db-connector-mule-4.xsd">
<configuration-properties file="mule-app.properties"/>
<http:listener-config name="HTTP_Listener_config">
<http:listener-connection host="0.0.0.0" port="8081"/>
</http:listener-config>
<azure-cosmos-db-connector-mule-4:key-token-config name="Cosmos_Db_Connector_Config">
<azure-cosmos-db-connector-mule-4:key-token-auth-connection key="${config.myKey}"
version="${config.version}"
baseUri="${config.baseUri}"/>
</azure-cosmos-db-connector-mule-4:key-token-config>
<azure-cosmos-db-connector-mule-4:resource-token-config name="Cosmos_Db_Connector_Config_Resource_Token">
<azure-cosmos-db-connector-mule-4:resource-token-auth-connection resourceToken="#[vars.resourceToken]"
version="${config.version}"
baseUri="${config.baseUri}"/>
</azure-cosmos-db-connector-mule-4:resource-token-config>
<flow name="list-documents-resource-token-flow">
<http:listener config-ref="HTTP_Listener_config" path="/list-documents-resource-token"/>
<flow-ref name="obtain-resource-token"/>
<azure-cosmos-db-connector-mule-4:list-documents config-ref="Cosmos_Db_Connector_Config_Resource_Token"
dbIdUriParam="${config.database}"
collIdUriParam="${config.collection}"
xMsConsistencyLevelHeader="SESSION"
ifNoneMatchHeader="noneMatch">
</azure-cosmos-db-connector-mule-4:list-documents>
<ee:transform>
<ee:message>
<ee:set-payload><![CDATA[%dw 2.0
output application/json
---
payload]]></ee:set-payload>
</ee:message>
</ee:transform>
<flow-ref name="clear-permissions"/>
<logger level="INFO" message="#[payload]"/>
</flow>
</mule>
Verify that your connector is configured.
Save the project.
From a web browser, test the application by entering http://localhost:8081/list-documents-resource-token.
This Mule flow obtains a list of existing stored procedures using short-lived tokens from the Resource Token authorization.
This example uses the following operations:
HTTP Listener
Accepts data from HTTP requests
Flow Reference
Obtains the resource token
List Stored Procedures
Returns a list of the stored procedures in the collection
Transform Message
Outputs the results of the List Stored Procedures operation in JSON format
Flow Reference
Clears the permissions
Logger
Shows the HTTP response from the List Stored Procedures operation
Paste this code into the Studio XML editor to quickly load the flow for this example into your Mule app:
<?xml version="1.0" encoding="UTF-8"?>
<mule
xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
xmlns:azure-cosmos-db-connector-mule-4="http://www.mulesoft.org/schema/mule/azure-cosmos-db-connector-mule-4"
xmlns:ee="http://www.mulesoft.org/schema/mule/ee/core" xmlns:http="http://www.mulesoft.org/schema/mule/http"
xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
http://www.mulesoft.org/schema/mule/ee/core http://www.mulesoft.org/schema/mule/ee/core/current/mule-ee.xsd
http://www.mulesoft.org/schema/mule/azure-cosmos-db-connector-mule-4 http://www.mulesoft.org/schema/mule/azure-cosmos-db-connector-mule-4/current/mule-azure-cosmos-db-connector-mule-4.xsd">
<configuration-properties file="mule-app.properties"/>
<http:listener-config name="HTTP_Listener_config">
<http:listener-connection host="0.0.0.0" port="8081"/>
</http:listener-config>
<azure-cosmos-db-connector-mule-4:key-token-config name="Cosmos_Db_Connector_Config">
<azure-cosmos-db-connector-mule-4:key-token-auth-connection key="${config.myKey}"
version="${config.version}"
baseUri="${config.baseUri}"/>
</azure-cosmos-db-connector-mule-4:key-token-config>
<azure-cosmos-db-connector-mule-4:resource-token-config name="Cosmos_Db_Connector_Config_Resource_Token">
<azure-cosmos-db-connector-mule-4:resource-token-auth-connection resourceToken="#[vars.resourceToken]"
version="${config.version}"
baseUri="${config.baseUri}"/>
</azure-cosmos-db-connector-mule-4:resource-token-config>
<flow name="list-stored-procedures-resource-token-flow">
<http:listener config-ref="HTTP_Listener_config" path="/list-stored-procedures-resource-token"/>
<flow-ref name="obtain-resource-token"/>
<azure-cosmos-db-connector-mule-4:list-stored-procedures config-ref="Cosmos_Db_Connector_Config_Resource_Token"
dbIdUriParam="${config.database}"
collIdUriParam="${config.collection}">
</azure-cosmos-db-connector-mule-4:list-stored-procedures>
<ee:transform>
<ee:message>
<ee:set-payload><![CDATA[%dw 2.0
output application/json
---
payload]]></ee:set-payload>
</ee:message>
</ee:transform>
<flow-ref name="clear-permissions"/>
<logger level="INFO" message="#[payload]"/>
</flow>
</mule>
Verify that your connector is configured.
Save the project.
From a web browser, test the application by entering http://localhost:8081/list-stored-procedures-resource-token.