We have created pipeline to deploy in Fucntion App using DevOps pipeline. In CD pipeline we have added first task to deploy to Function App which is successful. Second task was to import those functions in Function app to API. The below we tried :
It successfully Imported the function but the second time onwards its not updating the function. it threw error saying that "API with the same name already exists"
Hence we referred one article and developed the below code:

For this we are getting error as Null value for $api.apiVersionsetID. We output the value of $api to confirm this is null indeed.
Is there a way to update the functions in the existing API, as and when new functions are deployed in function app?
Update: There is a third party task in the market place to implement that but our project doesnt want to use that. they prefer only Microsoft recommended tasks.
