I'm attempting to put together a gulp script that will watch my changed files (front end files like css, js, cshtml) and will FTP them to my Azure WebApp the moment they are modified. I'm using gulp-ftp, but if there is a better option, please let me know.
gulp.src(cssRoot).pipe(
foreach(function (stream, rootFolder) {
gulp.watch([cssRoot + "/**/*.css", jsRoot + "/**/*.js", cshtmlRoot + "/**/*.cshtml"], function (event) {
if (event.type === "changed") {
console.log("publish file " + event.path);
gulp.src(event.path, { base: './' })
.pipe(ftp({
host: 'ftp://my-azure.website-ftp-url/',
user: 'my-azure-ftp-username\in-the-complete-form',
pass: 'my-azure-ftp-password',
remotePath: 'site\wwwroot\'
}))
.pipe(gutil.noop());
}
console.log("published " + event.path);
});
return stream;
})
);
});
I have checked the credentials for the FTP using FileZilla and it works fine. (I extracted them using the method here).
The watch seems to be working fine, however the FTP seems to be failing with the following error:
events.js:160
throw er; // Unhandled 'error' event
^
Error: getaddrinfo ENOTFOUND ftp://my-azure.website-ftp-url/ ftp://my-azure.website-ftp-url/:21
at errnoException (dns.js:28:10)
at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:76:26)
Does anyone know why it can't connect?
I'm also not sure if my script will copy the file to the relative location of the website, or if it'll go directly to the root.....but that's another question altogether.
As @Mark pointed out, please remove "ftp://" from your host value first.
Then you'll also need to double the "\" in the user value (ex: "someapp\\someuser"). See Vinyl-ftp strange error.