Unable to run python program on Azure Function App, despite successful execution locally

Terry HL 20 Reputation points
2023-09-02T10:17:09.6033333+00:00

I encountered an issue while trying to run a Python program on Azure Function App. The program, which integrates with Google API and Notion API for calendar synchronization, runs successfully locally on my machine. However, when deployed to Azure Function App, it fails to run. I would like to seek assistance from the community on how to resolve this problem. Here are the specific details and error messages I encountered:

  1. The Python program runs without any errors and functions properly on my local machine.
  2. When deploying the program to Azure Function App, it fails to execute.
  3. I suspect there might be configuration or dependency issues specific to the Azure environment causing the program to fail.

I would greatly appreciate any guidance, advice, or suggestions on resolving this issue and successfully running the program on Azure Function App. Thank you for your assistance!

2023-09-02T10:02:35Z   [Information]   Executing 'Functions.TimerTrigger_UpdateGoogleCalendar' (Reason='This function was programmatically called via the host APIs.', Id=46c19074-20c5-433d-9b0e-6415319d76b9)
2023-09-02T10:02:35Z   [Verbose]   Sending invocation id: '46c19074-20c5-433d-9b0e-6415319d76b9
2023-09-02T10:02:35Z   [Verbose]   Posting invocation id:46c19074-20c5-433d-9b0e-6415319d76b9 on workerId:c3bc9b7e-85b2-47b6-922e-921837fbb514
2023-09-02T10:02:35Z   [Error]   Executed 'Functions.TimerTrigger_UpdateGoogleCalendar' (Failed, Id=46c19074-20c5-433d-9b0e-6415319d76b9, Duration=25ms)


I have used the following libraries

import requests
import os
import pickle
from google.oauth2.service_account import Credentials
from googleapiclient.errors import HttpError
from googleapiclient.discovery import build
Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
5,909 questions
0 comments No comments
{count} votes

Accepted answer
  1. navba-MSFT 27,540 Reputation points Microsoft Employee Moderator
    2023-09-04T06:35:59.92+00:00

    @Terry HL Welcome to Microsoft Q&A Forum, Thank you for posting your query here!

    I understand that you are encountering an issue while trying to run a Python program on Azure Function App. The program integrates with Google API and Notion API for calendar synchronization and runs successfully locally on their machine. However, when deployed to Azure Function App, it fails to run.

    Please follow the below action plans for now:

    1. Could you please check if all the required libraries and dependencies for Google API and Notion API are installed on the Azure Function App environment. Follow the steps mentioned here
    2. Please check if the suggestion provided here helps ?
    3. Could you please enable the Application insight logs for the FunctionApp and check if there are any invocation exceptions. You can enabled the AppInsights as explained here.You can enabled the AppInsights as explained here.
    4. Please check Functions metrics for the HTTP Server Errors at the time of the issue.
      User's image
    5. Please check the Function App detectors by navigating to the Diagnose and Solve Problems section in the Azure Portal for the Functions as shown below: You can rely on the Function Executions and Errors setting:
      User's image
    6. You can also query the FunctionLogs as shown below:
      User's image

    Note: If none of the above steps help, Please share the below details over an email at AzCommunity@microsoft.com ( with subject "Attn: Naveen") and include the below details:

    • Your Azure Function Name
    • You Azure Function App resource URI in below format: /subscriptions/XXXXXXXXXX/resourceGroups/XXXXXX/providers/Microsoft.Web/sites/XXXXXX
    • Most recent UTC time of the actual issue where you received HTTP 500 error

    I will look at the backend logs to identify the root cause.

    **
    Please do not forget to "Accept the answer” and “up-vote” wherever the information provided helps you, this can be beneficial to other community members.

    1 person found this answer helpful.

1 additional answer

Sort by: Most helpful
  1. Terry HL 20 Reputation points
    2023-09-04T17:37:24.9533333+00:00

    finally, I changed the google-api-python-client version to 1.8.0

    pip install google-api-python-client==1.8.0
    pip install oauth2client==4.1.3
    
    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.