Critical error: Could not connect to server when FTP to an Azure App Service

I was trying to connect to my Azure App Service Web App using FTP and I got this error:

Status:   Connection established, waiting for welcome message...
Status:   Initializing TLS...
Status:  Verifying certificate...
Status: TLS connection established.
Command: USER $ID
Response:   331 Password required
Command:   PASS ************************************************************
Response:  530 User cannot log in.
Error:   Critical error: Could not connect to server

So I tried using my publishing profile credentials which I discuss how to get for access KUDU here.  What you need to do is access the Azure portal, navigate to the Azure App Services Web App you want to FTP into and select the Get publish profile as shown in Figure 1.

image

Figure 1, get publish profile credentials for an Azure App Service Web App

Watch out though, because there are 2 sets of credentials in the *.PublishSettings file.  One for the Web Deploy and another for the FTP.  The difference has to do with the userName, where the Web Deploy userName is like:

userName=”$webAppName”

While the FTP userName is like:

userName=”webAppName\$webAppName”

The userPWD is the same for both Web Deploy and FTP.  This is useful to know in case your Azure App Service deployment credentials are not set or not working for some reason.  You might see something similar to Figure 2 if there are no deployment credentials set.

image

Figure 2, get or set deployment credentials for an Azure App Service Web App

Also, you can use the publishing credentials if prompted for credentials when performing a remote debugging session, as I discuss here.