Crear una llave pública de OpenSSH para una VM Ubuntu en Azure usando macOS

Cuando se crea una nueva máquina virtual en Windows Azure, tienes la opción de asignar una contraseña o usar una llave pública de SSH como tipo de autenticación.

Creating a new VM

Aunque normalmente estamos acostumbrados a usar contraseñas, sin importar que tan complejas sean, en muchos casos son compartidas con otras personas, adivinadas, escritas en post-its, etc., invalidando las medidas de seguridad que intentaban establecer.

Creando un servicio WCF para Azure Service Fabric (II)

Este post es parte de una serie acerca Service Fabric.

  1. Introducción a Service Fabric
  2. Creando un servicio WCF para Azure Service Fabric

Escribí un artículo para DotNetCurry acerca de WCF y Service Fabric. Pueden encontrarlo aquí.

Introducción a Service Fabric (I)

Este post es parte de una serie acerca Service Fabric.

  1. Introducción a Service Fabric
  2. Creando un servicio WCF para Azure Service Fabric

En el principio (en un tiempo no muy lejano) fue el servidor local y la vida del desarrollador era un caos. El equipo de IT (si no había uno, entonces el desarrollador) era responsable de que el servidor en donde se montaba una aplicación estuviera funcionando como debía. Era su culpa si esto no pasaba.

Después, con el aprovechamiento de la virtualización vino la nube y trajo, entre sus ventajas más notorias, el darnos la oportunidad de culpar transferir la responsabilidad a alguien más

 

¿Qué tiene que ver todo esto con este post? Microsoft Azure Service Fabric es una opción de Platform as a Service construida desde cero para soportar aplicaciones en la nube distribuidas, a gran escala y con alta disponibilidad. Inició como una propuesta para bases de datos en la nube (CloudDB) y actualmente es usada en productos estrella de Microsoft como Cortana, Skype for Business, Power BI, SQL Azure, etc.

Sus principales venajas estan en la facilidad que da a los desarrolladores en manejar elementos que van más allá de la funcionalidad como

  • Actualizaciones escalonadas
  • Log
  • Monitoreo y telemetría de los servicios
  • Manejo de fallas
  • Seguridad

De este modo el desarrollador puede enfocar sus esfuerzos y atencion en el código.

 

Microservicios

Aunque es normalmente asociado con microservicios, las ventajas de Service Fabric pueden aprovecharse en aplicaciones multi-capa, APIs, etc. Pero, ¿qué es son los microservicios?.  Aunque no hay una definición estándar, normalmente se caracterizan por separar la funcionalidad de una aplicación en partes más pequeñas. Estas partes son versionadas de manera independiente, pueden ser de cualquier tecnología, escalables y orientados resolver una parte concreta del problema que se está atacando. Es importante dejar claro que monolítico no es malo ni microservicios bueno. Todo depende del escenario y contexto.

Al ser distribuidos de manera independiente en nodos (contenedores, servidores, máquinas virtuales) diferentes agrupados dentro de un cluster en donde se lleva a cabo el proceso de réplica y partición, cada microservicio puede escalarse según sus necesidades propias.

 

Cluster

Service Fabric puede correr del mismo modo en Microsoft Azure, otras nubes como AWS e incluso en nubes privadas, ya sea en Linux o Windows. Incluso al momento del desarrollo, los componentes utilizados son iguales, lo que facilita el moverse de un entorno a otro cuando sea necesario. Esto es debido a que los componentes estan pensados para ser estandres y no es necesario realizar modificaciones de acuerdo al ambiente en donde se ejecute. El cluster provee un nivel de abstracción entre la aplicación y la infraestructura en que se ejecuten.; es un conjunto de nodos con los componentes instalados y configurados para comunicarse entre sí. Las principales características del cluster son

  • Puede soportar miles de nodos
  • Puede cambiarse dinámicamente
  • Es una unidad de aislamiento

 

Servicios

Service fabric provee un conjunto de servicios para facilitar la administración:

Cluster manager

Encargado de las operaciones referentes al cluster. Por default puede manejarse por medio de REST usando el puerto 19800 en HTTP y con TCP por el puerto 19000 usando Powershell.

Failover manager

Encargado de detectar cuando nuevos nodos se agregan al cluster, cuando se quitan, o cuando alguno falla y rebalancear para asegurar alta disponibilidad de los servicios.

Naming

Mapea los servicios con los endpoints, de manera que puedan comunicarse entre si.

Fault Analysis

Ayuda a introducir fallas a los servicios de manera que puedan probarse escenarios distintos de manera controlada.

Image Store

Contiene los bits de los servicios, el master del cual se hacen las copias que se replican en los nodos.

Upgrade

A cargo de actualizar los componentes de Service Fabric, exclusivamente en Azure.

 

Programming models

Cuando se trabaja con Service Fabric, se tienen 3 opciones para crear los servicios

Reliable services

Provee una manera simple de integrarse con Service Fabric cuando se crean los servicios, beneficiandose de las herramientas de plataforma.

Reliable actors

Construido sobre Reliable Services, es un framework que trabaja con unidades single-threaded llamadas Actors, basadas en el patrón de diseño con el mismo nombre.

Guest executable

Es sólo eso, un ejecutable que puede publicarse en un cluster sin integrarse completamente con la plataforma; Service Fabric sólo se asegura de que se encuentre corriendo. No importa el lenguaje, por lo que es una buena opción para llevar aplicaciones existentes.

Aplicaciones y servicios

Una aplicación es básicamente un conjunto de servicios, los cuales se definen en el archivo ApplicationManifest.xml; en términos de Service Fabric, a esto se le se denomina Application Type. De él creamos una instancia denominada Application Instance, que es la que contactamos en tiempo de ejecución, muy similar al concepto de clase e instancia en programación orientada a objetos. Del mismo modo pasa con Service Type y Service instance, además de que se compone de 3 partes: código, datos y configuración.

Cada uno de estos elementos tiene su propia versión, es decir puedo tener la versión 2.1.1 de mi Aplicación que se compone de 1 servicio con versión 1.0.0.

 


Con esto termina la introduccion; estos son los conceptos básicos de Service Fabric en los que nos basaremos para los siguientes tutoriales.

Install XAMPP on a Ubuntu 13.04 virtual machine running on Windows Azure

One of the many great things about Windows Azure is how easy you can create a virtual machine, no matter the OS of your preference. But for good or bad, your virtual machine will be fresh, so you need to work on setting up whatever you need to get to work.

Recently I needed to set up some web applications that I preferred to run on Linux, and for that I prefer to use XAMPP because of the simplicity of the installation process. But this time was not as straightforward as on my previous experiences, so then this is how I did it.

I’ll assume that you already have the virtual machine created; I chose an Ubuntu Server 13.04 instance from the gallery. After getting the virtual machine up and running, the first step I did was to download the latest XAMPP version from the Apache friends website.

sudo wget http://sourceforge.net/projects/xampp/files/XAMPP%20Linux/1.8.1/xampp-linux-1.8.1.tar.gz/download?use_mirror=iweb&download=

After that you need to extract the files from the tar, so we follow the process described for the XAMPP installation guide

sudo tar xvfz xampp-linux-1.8.1.tar.gz -C /opt

So far, so good. But when we try to start our XAMPP server using

sudo /opt/lampp/lampp start

We get the following error

XAMPP is currently only availably as 32 bit application. Please use a 32 bit compatibility library for your system.

To solve this, there are 2 posible solutions, both of them start by doing

sudo apt-get update

After this, you can install the ia32-lib package

sudo apt-get install ia32-lib

This solution worked for me on previous Ubuntu versions, but not this time. If this solution doesn’t work for you either, then you need to run the following command

sudo dpkg --add-architecture i386 && sudo apt-get update && sudo apt-get install ia32-libs

As stated in this askubuntu.com answer,

(…) installing through WUBI did not correctly detect the available foreign architectures. As tumbleweed suggested printing the foreign architectures probably returns nothing. Add i386 as a foreign architecture, update the apt cache, then install the 32 bit libs.

So then now you might be able to start your XAMPP server by

sudo /opt/lampp/lampp start

You should now get something like this

Starting XAMPP 1.8.1...
LAMPP: Starting Apache...
LAMPP: Starting MySQL...
LAMPP started.

With this you have successfully installed your XAMPP server, the next step is to test your web server. When you create a new virtual machine, by default the only open port is the one designed for SSH. In order to access the server via a different port we need to create a new endpoint. On the Virtual Machine administration page, go to the endpoints tab


There you will see the list of the endpoints that we already have. If it is a new VM you might see only the one corresponding to SSH.

Click on ADD ENDPOINT button at the bottom of the page, and you will see the small window to create a new endpoint.

Click on Next button and you will see the window to specify the endpoint data


You can choose the name you want but it cannot be the same as an existing one; the protocol will be TCP. The public port is the one you will use to access your webserver, so it can be anything you want. The private port is the one your XAMPP server is using to serve the content. It is normally the 80, but you can change that on the XAMPP configuration accordingly to your needs.

After clicking the complete button, you should be able to see your new endpoint listed and now you can access your web server from any part in the world with something like this

http://[youthostname].cloudapp.net:[yourpublicport]

Once the page loads, you will most likely see the following error message

New XAMPP security concept:

Access to the requested object is only available from the local network.

This setting can be configured in the file "httpd-xampp.conf".

If you think this is a server error, please contact the webmaster.

So then what you need to do is modify the specified file. According to our installation, it will be located in /opt/lampp/etc/extra/ directory. We need to find the section with the title “New XAMPP security concept” and comment out the full LocationMatch section or adjust the values of the allowed IP addresses if you don’t want to open your site to the public.

Another change we need to make in the same file is on the Directory "/opt/lampp/phpmyadmin" section. We need to add there Requiere all granted to be able to access the phpMyAdmin site. Remember to add some IP filters so it is not open to anybody that has the URL address to access it.

To finish, just restart your XAMPP server

sudo /opt/lampp/lampp restart

And voilà, you are now ready to work with your XAMPP server on the cloud.

Overcome to Windows Azure free trial cancellation by adding a new plan

I decided to try Windows Azure more than 3 months ago, most likely because of it’s free 90-day offer. I can tell that I’m amazed on all the posibilies you have for free (Websites, Virtual machines, Mobile Services, etc.).

So then, I decided I wanted to continue with the service after my trial period ended by “acquiring” a Pay-As-You-Go plan (that as the name says, you pay only what you use only if you use it, so at the time of my purchase my total was $0.00).

Since I was swamped with many things at job, I didn’t payed much attention on the warning e-mails saying that my account was about to expire. As it might be expected, my account was cancelled 2 weeks ago. Last week I was trying to upgrade my account, so I signed up on the Pay-As-You-Go plan but after several tries and wating days, I still wasn’t able to use it to create new websites with it.

So this is the process that you need to follow in order to be able to use your new plan in your account:

  1. Acquire a new plan (Pay-As-You-Go, 6 or 12 month, etc.)
  2. Go to Preview Features page and select the feature that you want to enable for your new plan, in my case I wanted to be able to create websites again
  3. Click on “Try it now”
  4. Select the plan you want to associate (your new plan). In this case I’m showing an example with Media Services because I already joined to the Websites preview
After completing this, you will see a label on the screen saying that the feature is active
and you will be able to create websites (or any of the preview features that you selected) under your new plan
Sadly, my previous websites remain cancelled and it doesn’t seem to be possible to associate them with my new plan, or at least I couldn’t find a way to edit them on the manage portal.
So, if possible try to avoid your account cancellation, but if that already happened, this post might help you if your plan is not shown on some items on your account.

Tic-Tac-R source code

After some tweaks, I’m releasing the source code of the Tic-Tac-R game. As you may find on the previous post, this game is an experiment on how to make a simple Tic-Tac-Toe game in a real-time web application using SignalR and host it on a cloud environment using Windows Azure.

I hope you find it useful for learning just as I did

Download the source code on Github

Updates to Tic-Tac-R. Now it works on Windows Azure =)

This is an update of my previous post

Update: Post with the source code of the game

After spending a lot of time testing and searching on the web, I wasn’t able to get the Tic-Tac-R game on my Windows Azure website. I tried a lot of things and can shameless say that I was totally lost, since my application was working fine on a shared hosting environment (GoDaddy) but not on my Windows Azure.

Thanks to an anonymous user that replied my question on StackOverflow I was able to know that this is a weird issue only happening there with some sort of caching by Windows Azure (neither really a bug on my app nor SignalR). The suggestion was changing enforce the transport to be Long Polling and with that the app started to work no the cloud. It is kinda little slow though, and I feel that some times the call that I make from the browser is lost, but is’s maybe just my imagination… Time and more testing will give us the answer… In the meanwhile, you play the game can be part of the beta testers of this simple game… It’s free!! =P

By the way, I updated SignalR to the just released 0.5.3 version and everything seems to keep working fine..

I hope you can share your opinion regarding Tic-Tac-R. It will be really appreciated it =)

HealthyHarry: A healthy version of the traditional snake game over HTML5

As an experiment for learning HTML5 Canvas, I created this small game based on the popular “Snake” that many of us played on our old mobile phones (A Nokia 3320 in my case)

I deployed the game one of my Windows Azure websites and you can access it here. Initially I was thinking of buying a hosting account on a different place, but I think the cloud is a good place for host this kind of pet projects and Windows Azure is a great option, (IMHO) for 2 things: 1) Is extremely easy to use (saying creating websites, databases, deploying, etc) 2) It is free for 90 days, which is great if you are starting on the cloud “wave”. Let’s see what happen when the cloud bills begin to come.

So then, enjoy the game online for at least the next 60 days (when my free account expires :P)

The source code is hosted on Github. Feel free to do whatever you want with it