Share via

Deleted Function Keeps Running Alongside New Function in Function App

Developer2 0 Reputation points
2025-09-26T11:32:36.18+00:00

We have an Azure Function App with a function called Function_1. Initially, it worked fine, but after some time it started behaving strangely it kept fetching old environment variables and running outdated code, even after we updated both.

To fix this, we redeployed the same code under a new function name (Function_2). The new function works correctly it picks up the latest environment variables and reflects code changes. However, we still see logs from the old function instance, which seems to be running in the background even though it no longer appears in the Function App blade. Effectively, two instances are active:

The new function - works as expected, starts/stops correctly.

The old function - invisible in the portal but still running and logging activity.

We checked azure-webjobs-hosts/locks/... and found locks for both the old and new function listeners. We stopped the Function App and manually broke/deleted the blob leases for the old listener, which temporarily stopped it. But after restarting the Function App, the old function reappeared and started running again alongside the new one.

Application Insights also shows logs for both instances (old and new).

For your reference used below command to release and delete the old host from locks in blob storage

az storage blob lease break --container-name <container-name> \

--blob-name "locks/<lock-path>/Host.Functions.<OldFunction>.Listener" \

--account-name <storage-account> --account-key <key> --lease-break-period 0

az storage blob delete --container-name <container-name> \

--name "locks/<lock-path>/Host.Functions.<OldFunction>.Listener" \

--account-name <storage-account> --account-key <key>

Has anyone experienced this issue before? How can we completely remove the old function so only the redeployed one runs?

Azure Functions
Azure Functions

An Azure service that provides an event-driven serverless compute platform.

0 comments No comments

1 answer

Sort by: Most helpful
  1. Anonymous
    2025-10-09T16:12:24.08+00:00

    Hello Developer2

    Thanks for reaching out on Microsoft Q&A and really appreciate your patience while we looked into this.

    Understand from description that you are facing an issue with your Azure Function App, where an old function continues to run even after you've deleted it and deployed a new function under a different name. This can happen due to remnants left in the blob storage or functions being stuck due to locks.

    Steps:

    1. Check for Active Function Instances: Double-check Azure Portal to ensure the old function is not showing up in any slots or hidden sections.

    Release Blob Leases: You mentioned breaking/deleting blob leases, which is a good step. Make sure you’ve done this for all relevant blobs related to the old function, as sometimes there might be multiple locks.

    Delete App Settings & Configuration: If the old function has any associated application settings, remove these. Sometimes, remnants of settings can cause the system to reference old code.

    Restart the Function App: After making changes, restart the Function App. This can help ensure that your updates take effect.

    Use Application Insights: Check Application Insights to review the telemetry for more clues on what’s happening with the old function.

    Redeploy the New Function: As a last resort, it might help to redeploy your new function and ensure that no artifacts of the old function are present.

    Please provide the information below if none of the above steps work

    1. Checked the logs in Application Insights for the old function?
    2. Did you happen to make any app setting changes after deploying the new function?
    3. Are there any additional deployment slots that might hold the old function?
    4. Have you ensured that the old function does not appear in other parts of your Azure resources? 
    5. Function Name

    I hope this helps in resolving the issue, do let me know if you have any further questions on this.

    Thanks

    Was this answer helpful?

    0 comments No comments

Your answer

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