How to bulk insert CSV from Azure Blob to Azure Sql using Azure Function v2 (python)
jim01011
0
Reputation points
I have the following code below that inserts one line into an azure sql DB. How would I modify this code to bulk insert from Azure Blob (csvs) to Azure Sql using Azure Function v2 (python)?
import azure.functions as func
import logging
from azure.functions.decorators.core import DataType
import uuid
app = func.FunctionApp()
@app.function_name(name="HttpTrigger1")
@app.route(route="hello", auth_level=func.AuthLevel.ANONYMOUS)
@app.generic_output_binding(arg_name="toDoItems", type="sql", CommandText="dbo.ToDo", ConnectionStringSetting="SqlConnectionString",
data_type=DataType.STRING)
def test_function(req: func.HttpRequest, toDoItems: func.Out[func.SqlRow]) -> func.HttpResponse:
item_id = str(uuid.uuid4()) # Convert UUID to string
toDoItems.set(func.SqlRow({"Id": item_id, "title": "name", "completed": False, "url": "www"}))
return func.HttpResponse(f"Hello John")