admin管理员组文章数量:1402815
I'm trying to connect an Azure Function app, the premium one, that have the code uploaded in a docker image, that is uplod to the container registry. When I try to make a subscription in the Event Grid Topic, and connect it to the Function App, I condigue the endpoint to the Function App, and the function that I want to trigger, but doesn't arrive to the function app. It gives me this error: "message": "outcome=NotFound
This is my Dockerfile for the function app:
FROM mcr.microsoft/azure-functions/python:4-python3.11
ENV AzureWebJobsScriptRoot=/home/site/wwwroot \
AzureFunctionsJobHost__Logging__Console__IsEnabled=true
COPY ./src /home/site/wwwroot
COPY ./requirements.txt /home/site/wwwroot
COPY ./requirements_function_app.txt /home/site/wwwroot
RUN apt-get update
RUN apt-get install -y chromium chromium-driver
RUN apt-get clean
RUN rm -rf /var/lib/apt/lists/*
WORKDIR /home/site/wwwroot
RUN mkdir /home/site/wwwroot/process_url
RUN mv /home/site/wwwroot/azure_functions/process_url.py /home/site/wwwroot/process_url/process_url.py
RUN mv /home/site/wwwroot/azure_functions/function_process_url.json /home/site/wwwroot/process_url/function.json
RUN mkdir /home/site/wwwroot/delete_url
RUN mv /home/site/wwwroot/azure_functions/delete_url.py /home/site/wwwroot/delete_url/delete_url.py
RUN mv /home/site/wwwroot/azure_functions/function_delete_url.json /home/site/wwwroot/delete_url/function.json
RUN ls
RUN pip install --no-cache-dir -r requirements.txt
RUN pip install --no-cache-dir -r requirements_function_app.txt
And this is my azure function app:
import azure.functions as func
import logging
import json
from dotenv import load_dotenv
load_dotenv()
from utils.executor_functions import process_urls
app = func.FunctionApp(http_auth_level=func.AuthLevel.ANONYMOUS)
LOGGER = logging.getLogger()
LOGGER.setLevel(logging.DEBUG)
@app.function_name(name="process_url")
@app.event_grid_trigger(arg_name="azeventgrid")
async def process_url_fa(azeventgrid: func.EventGridEvent) -> func.HttpResponse:
logging.info('Python HTTP trigger function processed a request.')
And this the JSON:
{
"scriptFile": "process_url.py",
"bindings": [
{
"authLevel": "anonymous",
"type": "eventGridTrigger",
"direction": "in",
"name": "process_url"
},
{
"type": "http",
"direction": "out",
"name": "$return"
}
]
}
I tried with the eventgrid endpoint that appears in Azure Portal, in the EventGrid resource
Any ideas to try?
I tried to connect it via webHook and with the function app url but doesn't work. I don't know where is the problem.
I'm trying to connect an Azure Function app, the premium one, that have the code uploaded in a docker image, that is uplod to the container registry. When I try to make a subscription in the Event Grid Topic, and connect it to the Function App, I condigue the endpoint to the Function App, and the function that I want to trigger, but doesn't arrive to the function app. It gives me this error: "message": "outcome=NotFound
This is my Dockerfile for the function app:
FROM mcr.microsoft/azure-functions/python:4-python3.11
ENV AzureWebJobsScriptRoot=/home/site/wwwroot \
AzureFunctionsJobHost__Logging__Console__IsEnabled=true
COPY ./src /home/site/wwwroot
COPY ./requirements.txt /home/site/wwwroot
COPY ./requirements_function_app.txt /home/site/wwwroot
RUN apt-get update
RUN apt-get install -y chromium chromium-driver
RUN apt-get clean
RUN rm -rf /var/lib/apt/lists/*
WORKDIR /home/site/wwwroot
RUN mkdir /home/site/wwwroot/process_url
RUN mv /home/site/wwwroot/azure_functions/process_url.py /home/site/wwwroot/process_url/process_url.py
RUN mv /home/site/wwwroot/azure_functions/function_process_url.json /home/site/wwwroot/process_url/function.json
RUN mkdir /home/site/wwwroot/delete_url
RUN mv /home/site/wwwroot/azure_functions/delete_url.py /home/site/wwwroot/delete_url/delete_url.py
RUN mv /home/site/wwwroot/azure_functions/function_delete_url.json /home/site/wwwroot/delete_url/function.json
RUN ls
RUN pip install --no-cache-dir -r requirements.txt
RUN pip install --no-cache-dir -r requirements_function_app.txt
And this is my azure function app:
import azure.functions as func
import logging
import json
from dotenv import load_dotenv
load_dotenv()
from utils.executor_functions import process_urls
app = func.FunctionApp(http_auth_level=func.AuthLevel.ANONYMOUS)
LOGGER = logging.getLogger()
LOGGER.setLevel(logging.DEBUG)
@app.function_name(name="process_url")
@app.event_grid_trigger(arg_name="azeventgrid")
async def process_url_fa(azeventgrid: func.EventGridEvent) -> func.HttpResponse:
logging.info('Python HTTP trigger function processed a request.')
And this the JSON:
{
"scriptFile": "process_url.py",
"bindings": [
{
"authLevel": "anonymous",
"type": "eventGridTrigger",
"direction": "in",
"name": "process_url"
},
{
"type": "http",
"direction": "out",
"name": "$return"
}
]
}
I tried with the eventgrid endpoint that appears in Azure Portal, in the EventGrid resource
Any ideas to try?
I tried to connect it via webHook and with the function app url but doesn't work. I don't know where is the problem.
Share Improve this question edited Mar 24 at 8:24 Jucas22 asked Mar 21 at 13:20 Jucas22Jucas22 11 bronze badge 3- Welcome to SO. Provide more details on what you have tried so far, give more details similar to this question – Anand Sowmithiran Commented Mar 21 at 13:57
- @Jucas22 could you please provide your Your Dockerfile, function signature, exact Event Grid endpoint URL you're using (without the key). – Sirra Sneha Commented Mar 24 at 5:21
- I edited the question with more information – Jucas22 Commented Mar 24 at 8:24
1 Answer
Reset to default 0To connect Azure Function App with Event Grid perform below mentioned steps:
- For creating the Event Grid subscription, use the below given link format:
https://<function-app-name>.azurewebsites/runtime/webhooks/EventGrid?functionName=<function-name>&code=<function-key>
- Try to use Azure CLI to create subscription (optional): -
az eventgrid event-subscription create name process-url-subscription source-resource-id /subscriptions/<sub-id>/resourceGroups/<rg>/providers/Microsoft.EventGrid/topics/<your-topic> endpoint https://<function-app-name>.azurewebsites/runtime/webhooks/EventGrid?functionName=process_url&code=<function-key>
- Update your azure function app with this: -
import azure.functions as func
import logging
from dotenv import load_dotenv
load_dotenv()
from utils.executor_functions import process_urls
app = func.FunctionApp(http_auth_level=func.AuthLevel.ANONYMOUS)
@app.function_name(name="process_url")
@app.event_grid_trigger(arg_name="azeventgrid")
async def process_url_fa(azeventgrid: func.EventGridEvent) -> func.HttpResponse:
logging.info('Python HTTP trigger function processed a request.')
return func.HttpResponse("Processed Event Grid event!", status_code=200)
- update your Function. json file with this: -
"bindings": [
{
"type": "eventGridTrigger",
"direction": "in",
"name": "azeventgrid"
},
{
"type": "http",
"direction": "out",
"name": "$return"
}
]
- In reference to this, you can also check the Microsoft documentation that I've attached:
docs1, docs2
本文标签: pythonHow to connect Azure Function App with Event GridStack Overflow
版权声明:本文标题:python - How to connect Azure Function App with Event Grid - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744350448a2602016.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论