Your Must-Have PowerShell Aliases for Docker (Elton Stoneman) - This post is gold! Seriously, it has a lot of really good code snippet ready to use and if gave me so many ideas...
The First 20 Hours: How to Learn Anything...Fast (Josh Kaufman) - That was a very interesting book. I devoured it much faster than I thought! As I was reading it, I was thinking... hey as a developer/programmer I already do a lot of those things... Things change so fast, technology changes... And a few pages later, the author was saying the same thing. :) It looks like we can adapt to many deferent situations. The author share with us a few journeys as he was learning new stuff. While I may not be interested to learn how to play to Go, I found all part of the book very interesting as those journeys a pact with tons of information.
ISBN: 1591845556 (ISBN13: 9781591845553)
elementary OS 5 Juno is Here – elementary – Medium (Cassidy James Blaede) - ELementary was already one of my favorite Linux distribution. With this new version named Juno it's just... Hmmmm so smooth and beautiful. Try it you will see.
Creating the perfect MVP Summit (Charles Sterling) - The MVP summit is a very special event. However, these suggestions are also applicable to other technical event.
For a project I have, I wanted to validate if containers were easier to use compare to regular code with services in Azure. I needed to refresh myself with Docker, so I decide to do what I thought would be a simple test: Create an Asp.Net Core web site in a container and access it on my machine.
This post is about my journey to finally achieve this goal, as you may guess it didn't work on the first attempt.
The Goal
One reason why I was looking at containers, it's because it's supposed to be working everywhere right? Well yes but sometimes with a little of effort. The goal here is to be able to run the same container on my main PC, my surface, a Linux VM and of course in Azure.
The context
I have a different setup on my main machine and on my surface. On my PC, I'm using VirtualBox for my VMs so I'm not running Docker for windows, but Docker Toolbox. This flavor (older version) of Docker will create a VM in VitualBox instead of Hyper-V. I couldn't use Docker for Windows like on my Surface, because the two virtualization softwares don't run side by side.
I also wanted to use only tools available on each of this platform, so I decided not to use Visual Studio IDE (the big one). Moreover, I wanted to understand what was happening so I didn't want too much magic involve. Visual Studio is a fantastic tool and I love it. :)
Installing Docker
I needed to install Docker on my Surface. I downloaded Docker Community Edition (CE), and because Hyper-V was already installed everything ran smoothly. On Windows, you need to share the "C" drive from the Docker setting. However, I was getting a strange "bug" when trying to share mine. It was asking my to login with AzureAD and was ignoring my request by letting the share drive unchecked.
Thanks to my new friend Tom Chantler, I did search for too long. See the thing is I'm using an AzureAD account to login, and something is not working right at the moment. As explained in Tom's post: Sharing your C drive with Docker for Windows when using Azure Active Directory, to walkaround this situation, I only had to create a new user account with the exact name as my AzureAD account, but without the AzureAD prefix (ex: AzureAD\FBoucher became FBoucher). Once that was done I could share the drive without any issue.
Let's get started with the documentation
The HelloWord container worked like a charm, so I was ready to create my Asp.Net Core website. My reflex was to go on docs.docker.com and follow the instruction from Create a Dockerfile for an ASP.NET Core application. I was probably doing something wrong, because it didn't work. So I decided to start from scratch and do every step manually... I always learn more that way.
Let's start by the beginning
Before moving everything in a container, we need a web application. This can be easily done from the terminal/ command prompt, with the commands:
dotnet new mvc -o dotnetcoredockerappservicedemo
cd dotnetcoredockerappservicedemo
dotnet restore
dotnet publish -c release -o app/ .
Here we create a new folder with a website using the mcv template. I then go in that new folder and restore the Nuget package. To test the we site locally simply use dotnet run. And finally, we build and publish the application into the subfolder app.
Moving to Docker
Now that we have our app it's time to containerize it. We need to add some Docker instruction in a dockerfile. Add a new file name dockerfile (no extension) to the root folder and copy/paste these commandes:
To start Docker with Docker Tool just start the Docker Quickstart Terminal
This instruction will specify how to build our container. First, it will download the image microsoft/aspnetcore or microsoft/dotnet:2.1-aspnetcore-runtime. We specify the work directory, then copy the app folder to app folder inside the container. Finally, we specify the entry point of our application telling it to start with dotnet.
Like Git and it's gitIgnore file docker has the same thing with .dockerignore (no extension). Add that file into your folder to ignore the bin and obj folder.
# .dockerignore
bin\ obj\
Now that the instructions about how to build our container are completed, we can build our container. Execute the following command:
docker build -t dotnetcoredockerappservicedemo .
This will build dotnetcoredockerappservicedemo from the current folder.
Running Docker container locally
Everything is in place, the only thing missing is to run it. If you want to run it locally just go with this command:
docker run -p 8181:80 dotnetcoredockerappservicedemo
On my machine, the port 80 is always used. So I remap the port 80 to 8181, feel free to change it at your convenience. The website will be available at localhost:8181
If you are running Docker Tool (older version of Docker), you need to get the IP of your VM. To get it do
docker-machine ip
Running in the cloud
To run our container into Azure you will need to publish it to the cloud first. It could be on DockerHub or in a private registry on Azure. I decided to go with Azure. First, we need to create a registry, then publish our container.
az group create --name dotnetcoredockerappservicedemo --location eastus
az acr create --resource-group dotnetcoredockerappservicedemo --name frankContainerDemo01 --sku Basic --admin-enabled true
az acr credential show -n frankContainerDemo01
The last command az acr credential show will provides information to tag our container with our repository name and also gives us the credential to be able to push. Of course, you could go to the portal.azure.com and get the information from the Registry's Access Keys blade.
docker tag dotnetcoredockerappservicedemo frankcontainerdemo01.azurecr.io/dotnetcoredockerappservicedemo:v1
Let's connect our docker to our registry, and then push (upload) our container to Azure.
# The https:// is important...
docker login https://frankcontainerdemo01.azurecr.io -u frankContainerDemo01 -p <Password_Retreived>
docker push frankcontainerdemo01.azurecr.io/dotnetcoredockerappservicedemo:v1
Great the container is in Azure. Now let's create a quick webApp to see it. We could also use the Azure Container Instance (ACI) that would be only one command, but because the demo is a website, it won't make sense to use ACI for that.
To get an Application service, we need a Service plan, and then we will create an "empty" webapp. To do that we will specify the runtime without providing any code/binary/container. I wasn't able to create a webapp from a private Azure registry in one command, so this is why I'm doing it in two.
az appservice plan create --name demoplan --resource-group dotnetcoredockerappservicedemo --sku S1 --is-linux
az webapp create -g dotnetcoredockerappservicedemo -p demoplan -n frankdockerdemo --runtime "DOTNETCORE|2.1"
On Windows, I got the following error message: '2.1' is not recognized as an internal or external command, operable program or batch file. The PowerShell command line escape "--%" solves the problem: az --% webapp create -g dotnetcoredockerappservicedemo -p demoplan -n frankdockerdemo --runtime "DOTNETCORE|2.1"
If you check the website right now you should have page saying that the site is up but empty. Let's update the container settings with our registry and container settings.
az webapp config container set -n frankdockerdemo -g dotnetcoredockerappservicedemo --docker-custom-image-name frankcontainerdemo01.azurecr.io/dotnetcoredockerappservicedemo:v1 --docker-registry-server-url https://frankcontainerdemo01.azurecr.io --docker-registry-server-user frankContainerDemo01 --docker-registry-server-password <Password_Retreived>
It's works of course!
Conclusion
It's only four steps: create the .Net Core application, package it into a Docker container, publish our container into our Azure Registry, and create an application service base on that container. However, because all this tech are cross-platform, sometimes you get some little tiny differences between the platform, and those could become time-consuming. It was a great little project that turned out to be a lot more than expected, but I learn so much!
I'm very happy with the result... expect more of Docker in the future!
New recommendations in Azure Advisor (Kaitlyn Corazao) - This post provides a few more reasons to start looking at the advisor (but I'm sure you all already doing it.)
How to setup ASP.NET Core 2.1 on Linux in under 10 minutes (Daniel Crabtree) - Nice tutorial that goes further tthan simply the creation of the hello word application by showing some debugging configuration, and executing alternatives.
Power BI and Sudoku – Yes Please (Mike Carlo) - Awesome! I really like when people think outside of the box. This post gives you link to the game and to a more detailed post.
Why Developers Should Install WSL Today (Matt Hyon, August Banks) - I love WSL (aka Bash on Windows). It has evolved, and become something much more. After ready this post you will either install it right away or smile because it's already installed.
Why Responsive Web Design? (Chris Love) - A nice post that explains clearly why you really need to think responsive design, even more in 2018.
The RULES of Blogging (Darren Rowse) - If you are already bloging, or thinking about starting, take two minutes and watch this short video... The rules are.... Simple.
Copy, Download or Upload from-to any combination of Windows, Linux, OS X, or the cloud
Data is and will always be our primary concern. Whether shaped as text files, images, VM VHDs or any other ways, at some point in time, our data will need to be moved. I already wrote about it previously, and the content of this post is still valuable today, but I wanted to share new options and convert all ground (meaning Linux, Windows and OS X).
Scenarios
Here few scenarios why you would want to move data.
Your Microsoft Azure trial is ending, and you wish to keep all the data.
You are creating a new web application, and all those images need to be moved to the Azure subscription.
You have a Virtual Machine that you would like to move to the cloud or to a different subscription.
...
AZCopy
AzCopy is a fantastic command-line tool for copying data to and from Microsoft Azure Blob, File, and Table storage. At the moment, to write this post AzCopy is only available for Windows users. Another solution will be introduced later in this post for Mac and Linux users. Before AzCopy was only available on Windows. However, recently a second version built with .NET Core Framework is available. The commands are very similar but not exactly the same.
AzCopy on Windows
In his simplest expression, an AzCopy command looks like this:
If you earlier have installed an Azure SDK on your machine, you already have it. By default, AzCopy is installed to %ProgramFiles(x86)%\Microsoft SDKs\Azure\AzCopy (64-bit Windows) or %ProgramFiles%\Microsoft SDKs\Azure\AzCopy (32-bit Windows).
If you need only AzCopy for a server, you can download the latest version of AzCopy.
Let's see some frequent usage. First let's say you need do move all those images from your server to an Azure blob storage.
These examples were simple, but AzCopy is a very powerful tool. I invite you to type one of the following commands to discover more about using AzCopy:
For detailed command-line help for AzCopy: AzCopy /?
For command-line examples: AzCopy /?:Samples
AzCopy on Linux
Before you could install AzCopy you will need to install .Net Core. This is done very simply with few commands.
It is very similar to the original version, but parameters are using -- and - instead of the / and where a : was required, it's now a simple space.
Uploading to Azure
Here an example, to copy a single file GlobalDevopsBootcamp.jpg to an Azure Blob Storage. We pass the full local path to the file into --source, the destination is the full URI, and finally the destination blob storage key. Of course, you could also use SAS token if you prefer.
To copy the image to a second Azure subscription, we use the command the source is now an Azure Storage URI, and we pass the source and the destination keys:
Azure CLI is a set of cross-platform commands for the Azure Platform. It gives tools to manipulate all Azure components, but this post will focus on azure storage features.
There are two versions of the Azure Command-Line Interface (CLI) currently available:
Azure CLI 2.0: written in Python, conpatible only with the Resource Manager deployment model.
Azure CLI 1.0: written in Node.js, compatible with both the classic and Resource Manager deployment models.
Azure CLI 1.0 is deprecated and should only be used for support with the Azure Service Management (ASM) model with "classic" resources.
Installing Azure CLI
Let's start by installing Azure CLI. Of course, you can download an installer but since everything is evolving very fast with not getting it from Node Package Manager (npm). The install will be the same, you just need to specify the version if you absolutely need Azure CLI 1.0.
sudo npm install azure-cli -g
To keep the previous scenario, let's try to copy all images to a blob storage. Unfortunately, Azure CLI doesn't offer the same flexibility as AzCopy,and you must upload the file one by one. However, to upload all images from a folder, we can easily put the command in a loop.
for f in Documents/images/*.jpg
do
azure storage blob upload -a frankysnotes -k YoMjXMDe+694FGgOaN0oaRdOF6s1ktMgkB6pBx2vnAr8AOXm3HTF7tT0NQWvGrWnWj5m4X1U0HIPUIAA== $f blogimages
done
In the previous command -a was the account name, and -k was the Access key. This two information can easily be found in the Azure portal. From the portal (https://portal.azure.com), select the storage account. In the right band click-on Access keys.
To copy a file (ex: a VM disk aka VHD) from one storage to another one in a different subscription or region, it's really easy. This time we will use the command azure storage blob copy start and the -a and -k are related to our destination.
The nice thing about this command is that it's asynchronous. To see the status of your copy just execute the command azure storage blob copy show
azure storage blob copy show -a frankshare -k YoMjXMDe+694FGgOaN0oPaRdOF6s1ktMgkB6pBx2vnAr8AOXm3HTF7tT0NQVxsqhWvGrWnWj5m4X1U0HIPUIAA== imagesbackup 20151011_151451.MOV
Azure CLI 2.0 (Windows, Linux, OS X, Docker, Cloud Shell)
The Azure CLI 2.0 is Azure's new command-line optimized for managing and administering Azure resources that work against the Azure Resource Manager. Like the previous version, it will work perfectly on Windows, Linux, OS X, Docker but also from the Cloud Shell!
Cloud Shell is available right from the Azure Portal, without any plugging.
Uploading to Azure
The command if the same as the previous version except that now the command is named az. Here an example to upload a single file into an Azure Blob Storage.
Let's now copy the file to another Azure subscription. A think to be aware is that --account-name and --account-key are for the destination, even if it's not specified.
If you prefer, I also have a video version of that post.
One More Thing
Sometimes, we don't need to script things, and a graphic interface is much better. For this kind of situation, the must is the Azure Storage Explorer. It does a lot! Upload, download, and manage blobs, files, queues, tables, and Cosmos DB entities. And it works on Windows, macOS, and Linux!
It's just the beginning
This post was just an introduction to two very powerful tools. I strongly suggest to go read in the official documentation to learn more. Use the comment to share all your questions and suggestion.
Azure Application Architecture Guide (Mike Wasson) - A free book (pdf only) with all the best of the AzureCAT team? You really don't want to miss that opportunity.
Understanding Azure Event Grid ( Jason Roberts) - Nice little post that introduces event grid, differentiate it from the service bus, and quickly go over the pricing.
7 Hidden Gems in Visual Studio 2017 (Visual Studio Team) - This post shares not the usual tips. Seriously, how many you already knew before reading the article?
Social Presentations with Mark Rendle (Carl and Richard) - That look like a very promising tool... except for the name that I continually forget... (but that's probably just me). I will definitely have a to the Github repo.
What is a Cloud Developer Advocate? (Jeremy Likness) - Great article. A few of my friends joined that team, and even though I already had this talk with them, now I have a better picture.
How to uninstall Scrum (Erwin Verweij) - When you will read that post (because you must read it... Seriously), you will smile, giggle and maybe even laugh.
Cloud
Azure Tips and Tricks Part 14 - Generate SSH public key to log into Linux VM with Cloud Shell (Azure Tips and Tricks Part 14 - Generate SSH public key to log into Linux VM with Cloud Shell was published on September 11, 2017.) - Doing a remote desktop on a Windows VM is trivial, but doing the same thing on a Linux machine required just a little more. After reading this post will be a walk in the park.
Why is Serverless Extensibility better than Webhooks? (Bobby Johnson) - A useful post that jumps right in the middle of the debate about the Webhook and serverless. Both are good but planning (as usual) is worth it.
Programming
API Versioning with Azure API Management (Darrel Miller) - Great post that helps to find the peace, or at least make your ideas, about what kind of rules, you should follow.
Microservices: The Good, the Bad and the Hype (Jennifer Riggins) - Nice post that explains some challenges when doing serversless. Because yes, it's a great architecture plan, but it's not magic.
Microsoft Azure Stack is ready to order now (Mike Neil) - It worth the time we wait, now hybrid solutions will be so much more simple to create. And I will definitely try that ASDK (dev version)
Nested Virtualization in Azure (Joy Fan) - A VM in a VM, it does sound like the movie Inception, but it's, in fact, very powerful.
Push your images to Azure CDN on publish with gulp (Shayne Boyer) - We all understand that CDN could seriously help our web application. Well, this post will show you that it could be really easy to implement and integrate to your CI/CD.
Migrating to Azure SQL Database (Gavin Payne) - Very interesting and complete post that regroups references and gives details about some of the alternatives when it's migration time.
Tips & Tricks: Cost savings using Logic Apps (Rene Brauwers) - Very interesting post where the author did the exercise of comparing different scenario's performances and prices.
Programming
What is Kubernetes? An Intro for Beginners (Paul Burt) - This post is the perfect starting point to know what is Kubernetes are and understands what it can do for you, without getting deep technical.
Shutting down CodePlex ( Brian Harry) - If you have a project sitting at Codeplex, don't panic. This post explains what will happen, and if you would like to migrate, what are your options.
Fixing Azure Portal Errors - Errors are inevitable, this post explains how to workaround most of them and when nothing works how let the support team knows.
Announcing Azure App Service MySQL in-app (preview) (Sunitha Muthukrishna) - Wow! Many PHP developers must be waiting for this since so long. It's a very good news, and I'm sure many Wordpress users will be extremely happy too.
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
Once it's all done you can type 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 demodotnetweb
We now want to create our new web project. This is done by the command dotnet new, but we need to specify the type otherwise it will create a console application.
dotnet new -t web
Now to download all the references (nuget packages) of our project required, execute the following command:
dotnet restore
Base on the speed of your Internet connection and how many dependencies are required, this can take from few seconds to more than one minute.
To test if our solution works locally type the command:
dotnet run
That will compile our solution and start an AspNetCore Internal hosting. Launch a web browser and go to http://localhost:5000 to see the App in action.
Deploy 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
After a minute or so you should have your WebApp online!