Comments (3)
Here's a quick snippet that might help that uses the Gremlin API from Python Functions:
in init.py
`import logging
import azure.functions as func
import ast
from ..shared_code import config
from gremlin_python.driver import client, serializer
def main(req: func.HttpRequest) -> func.HttpResponse:
logging.info('Python HTTP trigger function processed a request.')
if req.method == "POST":
byte_body = req.get_body()
logging.info(thi)
dict_body = ast.literal_eval(byte_body.decode("UTF-8"))
f_p = dict_body['fp']
s_p = dict_body['sp']
try:
x = client.Client('wss://' + config.endpoint + ':443/', 'g',
username='/dbs/' + config.database + '/colls/' + config.collection,
password=config.password,
message_serializer=serializer.GraphSONSerializersV2d0()
)
query = f"g.V('{f_p}').addE('knows').to(g.V('{s_p}'))"
logging.info("\tRunning this Grem query:\n\t{0}\n".format(query))
callback = x.submitAsync(query)
if callback.result() is not None:
logging.info("\tInserted this edge: \n\t{0}\n".format(callback.result().one()))
else:
logging.info("Something went wrong")
except Exception as e:
logging.info("there was an exception: {0}".format(e))
return func.HttpResponse(f"Hello {f_p}")
`
my function.json looks like this:
{ "scriptFile": "__init__.py", "bindings": [ { "authLevel": "anonymous", "type": "httpTrigger", "direction": "in", "name": "req", "methods": [ "get", "post" ] }, { "type": "http", "direction": "out", "name": "$return" } ] }
and then take a look here: https://github.com/Azure-Samples/azure-cosmos-db-graph-python-getting-started/blob/master/connect.py
Hope this helps!
from azure-functions-python-library.
Will route this VS Code Extension
from azure-functions-python-library.
Routed to VS Code asks
from azure-functions-python-library.
Related Issues (20)
- [BUG] Service Bus Session ID is not available to Function code HOT 2
- Python - azure.functions.WsgiMiddleware does not support multiple Set-Cookie response headers HOT 10
- BUG: Cosmos DB Document should not be filtering _ts
- This repo is missing important files
- Inconsistent naming get_json() in EventGridEvent and EventGridOutputEvent
- Support HTTPStatus IntEnum for status code return values. HOT 3
- [BUG] AsgiMiddleware starts an event loop which is never closed HOT 2
- [FeatureRequest] Add timer trigger for Python Programming Model V2
- [FeatureRequest] add to_dict to func.Document for CosmosDB HOT 1
- The load execution start time and program start gap is large - Azure Function APP HOT 1
- UploadFile not working with FastAPI Integration HOT 1
- Can't change default function name while using FastAPI HOT 4
- [FeatureRequest] Add EventGrid source option for blob_trigger HOT 3
- Retry policy removed from version 1.17.0
- Unable to run an Azure Python function in VSCode HOT 1
- WsgiFunctionApp with DispatcherMiddleware and registering new HTTP triggers blueprints HOT 1
- How to receive CloudEvent triggers?
- Python 3.11 not supported HOT 1
- HTTP Request/Response headers should be multidict HOT 2
- Implement read1 method for InputStream
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from azure-functions-python-library.