List User Defined Functions
Performing a GET on the UDF resource of a particular database, that is, the udfs URI path, returns a list of the UDFs in the collection.
Request
Method | Request URI | Description |
---|---|---|
GET | https://{databaseaccount}.documents.azure.com/dbs/{db-id}/colls/{coll-id}/udfs |
The {databaseaccount} is the name of the Azure Cosmos DB account created under your subscription. The {db-id} value is the user generated name/ID of the database where the UDFs reside, not the system generated ID (rid) of the database. The {coll-id} value is the name of the collection where the UDFs reside. |
Headers
See Common Azure Cosmos DB REST request headers for headers that are used by all Cosmos DB requests.
Body
None.
Response
Headers
See Common Azure Cosmos DB REST response headers for headers that are returned by all Cosmos DB responses.
Status codes
The following table lists common status codes returned by this operation. For a full list of status codes, see HTTP Status Codes.
HTTP status code | Description |
---|---|
200 Ok | The operation was successful. |
Body
Property | Description |
---|---|
_rid | It is a system generated property. The resource ID (_rid) is a unique identifier that is also hierarchical per the resource stack on the resource model. It is used internally for placement and navigation of the UDF resource. |
_count | The number of UDFs returned. |
UserDefinedFunctions | |
id | It is a unique name to identify the UDF. |
body | It is the body of the UDF. |
_rid | It is a system generated property. The resource ID (_rid) is a unique identifier that is also hierarchical per the resource stack on the resource model. It is used internally for placement and navigation of the UDF resource. |
_ts | It is a system generated property. It specifies the last updated timestamp of the resource. The value is a timestamp. |
_self | It is a system generated property. It is the unique addressable URI for the resource. |
_etag | It is a system generated property that specifies the resource etag required for optimistic concurrency control. |
{
"_rid": "Sl8fALN4sw4=",
"UserDefinedFunctions": [{
"body": "function tax(income) {\r\n if(income == undefined) \r\n throw 'no input';\r\n if (income < 1000) \r\n return income * 0.1;\r\n else if (income < 10000) \r\n return income * 0.2;\r\n else\r\n return income * 0.4;\r\n}",
"id": "simpleTaxUDF",
"_rid": "Sl8fALN4sw4BAAAAAAAAYA==",
"_ts": 1449688293,
"_self": "dbs\/Sl8fAA==\/colls\/Sl8fALN4sw4=\/udfs\/Sl8fALN4sw4BAAAAAAAAYA==\/",
"_etag": "\"060072e4-0000-0000-0000-56687ce50000\""
}],
"_count": 1
}
Example
GET https://contosomarketing.documents.azure.com/dbs/volcanodb/colls/volcano1/udfs HTTP/1.1
x-ms-session-token: 39
x-ms-date: Wed, 09 Dec 2015 19:15:47 GMT
authorization: type%3dmaster%26ver%3d1.0%26sig%3dFwVMfm53ehSj5bK4rVu1PUvwRljDiBqD3PLfv1rkymk%3d
Cache-Control: no-cache
User-Agent: contoso/1.0
x-ms-version: 2015-08-06
Accept: application/json
Host: contosomarketing.documents.azure.com
Cookie: x-ms-session-token=39
Connection: Keep-Alive
HTTP/1.1 200 Ok
Cache-Control: no-store, no-cache
Pragma: no-cache
Content-Type: application/json
Content-Location: https://contosomarketing.documents.azure.com/dbs/volcanodb/colls/volcano1/udfs
Server: Microsoft-HTTPAPI/2.0
Strict-Transport-Security: max-age=31536000
x-ms-last-state-change-utc: Thu, 26 Nov 2015 05:55:14.602 GMT
x-ms-resource-quota: functions=25;
x-ms-resource-usage: functions=1;
x-ms-item-count: 1
x-ms-schemaversion: 1.1
x-ms-alt-content-path: dbs/volcanodb/colls/volcano1
x-ms-content-path: Sl8fALN4sw4=
x-ms-session-token: 39
x-ms-request-charge: 1
x-ms-serviceversion: version=1.5.57.3
x-ms-activity-id: 06e8f9c5-00a2-4bb2-8b09-b00b47ddf914
Set-Cookie: x-ms-session-token=39; Domain=contosomarketing.documents.azure.com; Path=/dbs/volcanodb/colls/volcano1
x-ms-gatewayversion: version=1.5.57.3
Date: Wed, 09 Dec 2015 19:15:48 GMT
Content-Length: 528
{
"_rid": "Sl8fALN4sw4=",
"UserDefinedFunctions": [{
"body": "function tax(income) {\r\n if(income == undefined) \r\n throw 'no input';\r\n if (income < 1000) \r\n return income * 0.1;\r\n else if (income < 10000) \r\n return income * 0.2;\r\n else\r\n return income * 0.4;\r\n}",
"id": "simpleTaxUDF",
"_rid": "Sl8fALN4sw4BAAAAAAAAYA==",
"_ts": 1449688293,
"_self": "dbs\/Sl8fAA==\/colls\/Sl8fALN4sw4=\/udfs\/Sl8fALN4sw4BAAAAAAAAYA==\/",
"_etag": "\"060072e4-0000-0000-0000-56687ce50000\""
}],
"_count": 1
}