Reputation: 425
I'm looking for a script (for example PowerShell) to deploy an ASP.NET 5 / MVC 6 application to Azure website. Ideally it would be a single script that builds the project and deploys it to Azure.
I would also like to run Entity Framework 7 migrations and do some custom JavaScript minification/bundling in the script.
I would really appreciate if any of you have ideas on how this can be accomplished, thanks!
Upvotes: 3
Views: 523
Reputation: 15603
Let's separate topics first.
For deploying a Web app to Azure, why not use Continuous Integration? If you link your Web App with your repository, you can pick a branch and everytime you push to that branch, it gets deployed on Azure.
You can go a step further and configure Deployment Slots (a staging one in particular) and configure Auto-Swap to reduce Cold starts.
For Javascript minification, you can just use Gulp/Grunt with tasks that either, run on your development environment (and you commit to your repository the minified output) or you can run the tasks as a "postrestore" action defined in your project.json file. A simple:
{
"scripts": {
"postrestore": ["npm install", "bower install","gulp default"]
}
}
Will do the trick by pulling your defined bower packages and then running the default gulp task.
Your default gulp task can be something like:
var gulp = require('gulp');
var mainBowerFiles = require('main-bower-files');
var bower = require('gulp-bower');
var uglify = require('gulp-uglify');
var ignore = require('gulp-ignore');
var del = require('del');
var project = require('./project.json');
var lib = project.webroot + '/dist';
gulp.task('clean',function(done){
del(lib, done);
});
gulp.task('bower:install', ['clean'], function () {
return bower();
});
gulp.task('default', ['bower:install'], function () {
return gulp.src(mainBowerFiles())
.pipe(ignore.exclude([ "**/*.css","**/*.less" ]))
.pipe(uglify())
.pipe(gulp.dest(lib+'/js'));
});
Upvotes: 2
Reputation: 1105
You can use both PowerShell and Visual Studio Team Services to automate the deployment of your web app in Azure.
For example, it's possible to make a workflow that executes some PowerShell script that executes DNU restore, code migrations and then publish the web app as soon as a commit is done on your source code repository.
I think the following article will help you: https://msdn.microsoft.com/en-us/Library/vs/alm/Build/azure/deploy-aspnet5
Hope this helps,
Julien
Upvotes: 0