# NOT RUN {
endp <- cosmos_endpoint("https://myaccount.documents.azure.com:443/", key="mykey")
db <- get_cosmos_database(endp, "mydatabase")
# importing the Star Wars data from dplyr
cont <- endp %>%
get_cosmos_database(endp, "mydatabase") %>%
create_cosmos_container(db, "mycontainer", partition_key="sex")
create_udf(cont, "times2", "function(x) { return 2*x; }")
list_udfs(cont)
# UDFs in queries are prefixed with the 'udf.' identifier
query_documents(cont, "select udf.times2(c.height) t2 from cont c")
delete_udf(cont, "times2")
# }
Run the code above in your browser using DataLab