admin管理员组

文章数量:1384310

I am experiencing persistent issues with my Azure Function App (Shutdown_Function), which I am trying to deploy in my subscription.

Issue Description: I am creating an Azure Function with a Cosmos DB Trigger via the Azure Portal, but immediately after creation, I receive the following error:

❌ Error Message in the Function App:

"Error while loading. Ask questions and use troubleshooting tools to investigate these errors. Diagnose and solve problems. Encountered an error (InternalServerError) from host runtime."

Important: This happens immediately after the function is created, before I even deploy my code.

Steps Taken to Troubleshoot:

  • First Deployment Attempt via Azure CLI and Visual Studio Code → Unsuccessful Deployment via CLI failed. I then created a new Function App with its own Storage Account.

  • Added Environment Variables (Before Creating the Function):

COSMOS_DB_CONNECTION_STRING
IOT_HUB_CONNECTION_STRING
EVENT_GRID_ENDPOINT
EVENT_GRID_KEY
  • Created the Function in Azure Portal
Function Type: Cosmos DB Trigger
Programming Model: V2
Job Type: Append to App
Function Name: shutdown_function
Container Name (Cosmos DB): DeviceStatus
Database Name: IoTDeviceData
Cosmos DB Connection: COSMOS_DB_CONNECTION_STRING
  • Function Creation in Azure Portal → Notification: "Successfully created shutdown_function" Despite this success message, I immediately receive the InternalServerError. No code has been deployed at this point.

  • Function Sometimes Disappears After Creation: In some cases, the function was initially created successfully, and the template was displayed.However, after a short time, the function disappeared.

What is causing the InternalServerError immediately after creation? Why does the function sometimes disappear shortly after creation?

See above. Deployed function in Visual Studio and in the portal ...

My script I want to deploy:

import logging
import json
import os
import azure.functions as func
from azure.iot.hub import IoTHubRegistryManager
from azure.eventgrid import EventGridPublisherClient
from azure.core.credentials import AzureKeyCredential

# 

本文标签: Issues with Azure Function App (ShutdownFunction) – InternalServerErrorStack Overflow