Restoring Deleted Function Code
The three hosting models for Azure Functions are Consumption (serverless), Dedicated, and Premium (hybrid of dedicated and serverless). Depending on the type of function used dictates if and how the function app code can be restored.
Restoring Deleted Code from Consumption and Premium Functions
Consumption and Premium by default require users to have an app setting WEBSITE_CONTENTAZUREFILECONNECTIONSTRING that designates where the functions code will be hosted inside of an Azure Files storage account. If your function app is deleted but the storage account remains you can find the Function apps code in the storage account under a path as described here depending on how the setting is used. If the storage account is deleted, please reach out to the Azure Storage team with a support case to see if they can restore the storage account. The undelete features for Function Apps and Web Apps in the dedicated plan cannot be used for Consumption and Premium Functions.
Restoring from Dedicated Functions
Dedicated functions utilize the same storage architecture that Azure Web Apps use. To restore a deleted Function App from the dedicated plan please utilize the Undelete for App Service feature. We recommend for source code that is not hosted in source control to make sure to backup code regularly to avoid disruptions.
When the function app is restored make sure all the proper app settings (storage and other queue resource connection strings) are present otherwise the function runtime will not startup or your function may not execute.