Debugging an Azure Function in Visual Studio couldn't be any easier and it just works, unless it doesn't... At my current customer, all internet traffic has to pass through an NTLM authenticated proxy so we were faced with an error:
The remote server returned an error: (407) Proxy Authentication Required.
It's not so difficult to fix, once you know what to do and where to look.
Keep in mind this guide only works for Azure Functions v1!
In v1 of Azure Functions, the local CLI is just a .NET application and therefor has a config file that we can adjust to be more proxy-aware.
The challenge is to find this file, as it seems to be different with each version of Visual Studio and the way the CLI is installed on your system.
Visual Studio 2017
With Visual Studio 2017, you have to install the Azure Functions extension yourself. You can find the func.exe.config file at
Pick the highest version number that starts with 1 (at the time of writing this is 1.0.12).
Visual Studio 2019
With Visual Studio 2019, the Azure Functions tools are included. You can find the func.exe.config file at
Pick the highest version number that starts with 1 (at the time of writing this is 1.0.10).
Add proxy configuration
Use system proxy settings
In the func.exe.config file, add the following code snippet somewhere between the
<system.net> <defaultProxy enabled="true" useDefaultCredentials="true"> <proxy usesystemdefault="true" /> </defaultProxy> </system.net>
Custom proxy settings
The previous settings made the
407 Proxy Authentication Required error go away, but we were still facing not able to connect to the internet. In our case, this was due to the virtual machine being in one domain and the proxy requiring authentication for a different domain.
If you are facing something similar, the following snippet can help you out. In this case, we are not relying on the auto-detection but we manually specify the proxy URL with the authentication settings:
<system.net> <defaultProxy useDefaultCredentials="true" enabled="true"> <proxy usesystemdefault="true" proxyaddress="http://<UserName>:<Password>@<ProxyUrl>:<ProxyPort>" /> </defaultProxy> </system.net>
Remember to update the tokens with your own information!