Azure App Service: Using cURL for deployment


cURL is a command line tool that can be used to send or receive files. cURL.exe supports numerous protocols like HTTP, HTTPS, FTP, FTPS, SFTP, LDAP, TELNET, SMTP, POP3 etc. For more information please refer the below links:

https://en.wikipedia.org/wiki/CURL
https://curl.haxx.se/docs/

Syntax

curl.exe -T <path-to-file-that-needs-to-be-deployed> -u "username:password" "FTP URL"

From curl documentation

-T, --upload-file FILE Transfer FILE to destination
--url URL URL to work with -u, --user USER[:PASSWORD] Server user and password
--tlsuser USER TLS username
--tlspassword STRING TLS password
--tlsauthtype STRING TLS authentication type (default SRP)

Pre-Requisites:

  • Deployment over FTPS will work only if the version of the curl is SSL aware. Download it from here:

https://curl.haxx.se/download.html

  • FTP endpoint of the web app. You can get this from portal or from the publish profile of the web app (under FTP section search for publishURL)
  • Username and password for authentication (Either deployment or publish profile credentials. See this)
    • With user-level credentials (User specific): sitename\username
    • With site-level credentials (Site specific/publish profile) : sitename\$sitename

For FTPS

Deploying via FTP

  • Launch command prompt
  • Browse to the folder location where curl was downloaded and execute the following command:
C:\>curl -T C:\sample.war -u "kaushalp\$kaushalp:<password>" ftp://waws-prod-sg1-005.ftp.azurewebsites.windows.net/site/wwwroot/

image

Deploying via FTPS

While using cURL via FTPS (FTP over SSL), the following error may be encountered when trying to connect over HTTP.

image

The following error is seen because curl will try to verify the certificate received in the Server Hello and it fails as it couldn’t verify the CA who issued the certificate.

This problem can be addressed by using an additional parameter either --cacert or -k can be specified.

C:\>curl -T C:\sample.war -u "kaushalp\$kaushalp:<password>" ftps://waws-prod-sg1-005.ftp.azurewebsites.windows.net/site/wwwroot/ -k

-k, --insecure Allow connections to SSL sites without certs (H)

C:\>curl -T C:\sample.war -u "kaushalp\$kaushalp:<password>" ftps://waws-prod-sg1-005.ftp.azurewebsites.windows.net/site/wwwroot/ --cacert e:\tools\kaushal-bundle.crt

--cacert FILE CA certificate to verify peer against (SSL)

TROUBLESHOOTING

Error: "curl: (25) Failed FTP upload: 550"
image
This error is seen when the FTP URL does not contain a trailing slash "/".

More Information:

Here is the default list of CA's that are supported by curl: https://curl.haxx.se/ca/cacert.pem (This was the file that was downloaded under pre-requisites)

Users can generate their own crt file and pass it to CURL.


Comments (0)

Skip to main content