The other day, I was glued to my PC, and I had spare time (yah, I know very unusual). Since .Net Core 1.0 was just released few days before, I decide to give it a try. To add an extra layer of fun in the mix, I decided to do it from my Ubuntu VM. In less than 15 minutes, everything was done! I was so impressed I knew I needed to talk about it. That's exactly what this post is about.
The preparation
Before we get started, it's important to know which version of Ubuntu you are using, because some commands will be slightly different. To know the version you are running you simply need to click the gear in the top right of the desktop screen and select About this Computer. In my case, since I'm using Ubuntu 14.04 LTS, I will be using command related to this version. If you are using a different version, please refer to .NET Core documentation.Now we need to install .Net Core. Nothing more easy. Open a Terminal (Ctrl+Alt+T) and type those three commands:
# Setup the apt-get feed adding dotnet as repo
sudo sh -c 'echo "deb [arch=amd64] https://apt-mo.trafficmanager.net/repos/dotnet/ trusty main" > /etc/apt/sources.list.d/dotnetdev.list'
apt-key adv --keyserver apt-mo.trafficmanager.net --recv-keys 417A0893
# Get the latest packages
apt-get update
# Install .NET Core SDK
sudo apt-get install dotnet-dev-1.0.0-preview2-003121
dotnet --info and you should see something like that.Create the Local WebApp
From the same Terminal we will create an empty folder for our solution and move into it. Execute these commands.mkdir demodotnetweb
cd demodotnetwebdotnet new, but we need to specify the type otherwise it will create a console application.dotnet new -t webdotnet restoreTo test if our solution works locally type the command:
dotnet runDeploy to Azure
To deploy our new project to the cloud, we will use the continuous deployment capability of Azure. First, navigate to portal.azure.com and create a Web App.Once the the application is created, you should see the This web app as been created message when you navigate to the
[nameofWebApp].azurewebsites.net
It's now time to add a local Git repository. In the WebApp Settings select Deployment source. Click on the Configure Required Settings, then select the Local Git Repository option.
After setting the user credential for the repository, we can get the URL from the Essential section.
Back to our Ubuntu Terminal, we will have to execute these commands:
# create a git repository
git init
# commit all files
git commit -m "Init"
# Add the remote repository
git remote add azure https://username@demowebcore.scm.azurewebsites.net:443/demowebcore.git
# Push the code to the remote
git push azure master
Voila! That was fun!.
