I am trying to delete a function app so that I can recreate it but when I try to recreate it says it already exists
This is the command I used to delete app
az functionapp delete --name MyFunctionApp --resource-group azure-functions
Then I listed the fucntions list and it returned nothing since I have no other functions.
az functionapp list --output table
I even went as far as to delete the resource group where function resides. The resource group is gone
az group delete --name azure-functions
Yet when I try to run this code I get an error
az functionapp create --resource-group azure-functions2 --consumption-plan-location eastus --runtime python --runtime-version 3.11 --functions-version 4 --name MyFunctionApp --storage-account azurefunctions --os-type Linux
Error output
Website with given name MyFunctionApp already exists.
I can probably create one with a new name yes but I rather make sure I have cleaned house and I dont have any old loose ends that may cause confusion when I redeploy.
Is there some thing I am missing to delete somewhere. I deleted the resource that had the function I am at a loss here. I do have 1 more resource group but that has 0 functions.
2
Answers
Azure Function Apps have a global scope. A function app is stored globally despite of region or location in domain as
<name>.azurewebsites.net
. So, when you have deleted a function app, then someone might have created with that name due to which you are unable to create and you will get an error saying:Yes, you might have deleted but someone might have used it and created it.
According to SO-Thread1 and SO-Thread2 it says:
Even while creating it in Portal when i use common name demo98 it says not available and use some other unique name, it takes it:
the
az functionapp delete
command doesnt instantly delete. It schedules a background delete and hides the function from view. this is why it doesn’t appear inaz functionapp list
try waiting 15 mins before creating the function again.
I tend to use the portal for function delete as it gives a notification when the job is actually done.
also the delete command doesn’t remove the storage account depending on your setup you may need to delete that too.