Search code examples
azureazure-functionsserverlessazure-functions-core-tools

Dynamic proxies in Azure Functions Core Tools?


I'm using Azure Functions Core Tools v2.3.148 on my mac. I'm using it for local development and publishing my app. My app needs proxies, so I've defined all proxies in proxies.json file. During local development, Core Tools recognises the file but points to backendUris which are hardcoded there (=actual functions on Function App). So to fix the issue, I have to change backendUris before doing local development, manually. Is there any way to automate this or easily switch between local and actual backendUri functions? Any other suggestion is welcomed.


Solution

  • As long as the backendurl locates in the same Function app, we can take advantage of localhost to represent the host no matter it's on Azure site or locally. Check the doc.

    "backendurl": "https://localhost/api/FunctionName"
    

    If you have modified routePrefix(default is api) in host.json, change it accordingly.

    If auth level of http trigger is Admin or Function, we could append key(?code=xxx) to the backendurl, locally the key is ignored and will take effect after deployed.