Search code examples
azure-functionsazure-functions-core-tools

Could not find local host metadata file 'host.json'


I want to use azure-functions-core-tools "func durable delete-task-hub" this command to delete taskhub under a storage account (I have current context's storage's connection string). But when I run this command, it reports:

Could not find local host metadata file 'host.json' Unable to find project root. Expecting to find one of host.json, local.settings.json in project root.

Could I use this command to delete taskhub in azure portal?


Solution

  • Could I use this command to delete taskhub in azure portal?

    Azure Functions core Tools commands are used to run from your local IDE terminal or command prompt as mentioned in Microsoft Docs.

    Could not find local host metadata file 'host.json' Unable to find project root. Expecting to find one of host.json, local.settings.json in project root.

    You have to place your task hub name in the host.json file as the format specified in Azure Durable Functions Host.json settings.

    func durable delete-task-hub --task-hub-name TestHubName
    

    With this command, you can delete the all storage artifacts including Azure storage tables, queues, and blobs. associated with a particular task hub,

    When I run my Azure Durable Function, I came to know the Task Hub Name from the 1st result and passed to the above command, it successfully deleted:

    enter image description here

    Cleanup taskhubs Programmatically:

    Through code, you can clean up the taskhubs present in a storage account, refer to this GitHub Ticket for the code given by cgillum.