Upload
marco-parenzan
View
135
Download
1
Embed Size (px)
Citation preview
DEV03 – Migrare Applicazioni Web su Azure
Marco Parenzan
[email protected] - @marco_parenzan
http://www.innovazionefvg.net/
#CDays15 – Milano 24, 25 e 26 Marzo 2015
Grazie a
PlatinumSponsor
#CDays15 – Milano 24, 25 e 26 Marzo 2015
Speaker info/Marco Parenzan
Formazione & Divulgazione con 1nn0va
Microsoft MVP 2014 for Microsoft Azure
www.slideshare.net/marco.parenzan
www.github.com/marcoparenzan
marco [dot] parenzan [at] live [dot] it
www.innovazionefvg.net
@marco_parenzan
Cloud Architect.NET developerLoves Functional Programming, Html5 Game Programming and Internet of Things
Migrare applicazioni web su Azure
Questionario di valutazione:
http://aka.ms/cloudcommunitydays
Grazie della partecipazione
The code for this sessionhttps://github.com/marcoparenzan/CommunityDays2015
#CDays14 – Milano 25, 26 e 27 Febbraio 2014
Agenda
• «Open the Menu»
• «The Open Menu»
• Usare IaaS
• Migrare un sito Wordpress
• Migrare un sito Node.js
#CDays15 – Milano 24, 25 e 26 Marzo 2015
On Premises
You
sca
le, m
ake r
esi
lien
t an
d m
an
ag
e
Infrastructure
(as a Service)
Storage
Servers
Networking
O/S
Middleware
Virtualization
Data
Applications
Runtime
Man
ag
ed
by v
en
do
r
Yo
u s
cale
, m
ake
resi
lien
t &
man
ag
e
Platform
(as a Service)
Sca
le, re
silien
ce a
nd
man
ag
em
en
t b
y v
en
do
r
Yo
u m
an
ag
e
Storage
Servers
Networking
O/S
Middleware
Virtualization
Applications
Runtime
Data
Software
(as a Service)
Storage
Servers
Networking
O/S
Middleware
Virtualization
Applications
Runtime
Data
Storage
Servers
Networking
O/S
Middleware
Virtualization
Data
Applications
Runtime
Sca
le, re
silien
ce a
nd
man
ag
em
en
t b
y v
en
do
r
Open the menu: IT as a Service
#CDays15 – Milano 24, 25 e 26 Marzo 2015
The “open” menu
The “classic”
• Wordpress/PHP
• MySql
• Node.js/Javascript
• Redis
The “new-age”
• .NET/C# open sourced
• ASP.NET open sourced
• Entity Framework open sourced
Microsoft Azure
#CDays14 – Milano 25, 26 e 27 Febbraio 2014
Using IaaS
#CDays14 – Milano 25, 26 e 27 Febbraio 2014
Using IaaS
• Azure VM• Choose Size: CPU, Memory, Add Disk as you need
• Deploy machine
• Connect via RDP• …or manage via Azure API
• You handle entire OS• Define roles
• Activate features
• Configure security
• Install software
#CDays14 – Milano 25, 26 e 27 Febbraio 2014
Publish Wordpress with IaaS
• Install XAMPP
• Download Wordpress from ….
• Create MySql database (from phpMyAdmin)
• Open port 80 (http) inbound requests on Windows Firewall
• Open http port (again 80) from Azure Management Portal• Configure
• Browse to http://<youvmname>.cloudapp.net/
• Start configuring Wordpress site!
#CDays14 – Milano 25, 26 e 27 Febbraio 2014
Using PaaS as Operations
#CDays14 – Milano 25, 26 e 27 Febbraio 2014
Create Azure Web Site
• Management Portal
• Web Sites
• Create new Website• Choose plan (free, shared, basic, standard)• Give a unique name “<mysite>.azurewebsites.net• You can than configure a custom 2nd level domain (only with basic and
standard plans)• You are online in seconds
• PHP is supported since the beginning• Not needed to configure FastCgi• Choose you right version
#CDays14 – Milano 25, 26 e 27 Febbraio 2014
Create a deployment slot
• Optimal to manage a testing deployment• …and then going online
• Create a deployment slot• Give it a name: <youname>-<deploymentname>.azurewebsites.net
• Jump to GitHub and create a repository
• Back to Azure Management Portal and configure deployment from Source Control• Autorize Azure to access to you GitHub account
#CDays14 – Milano 25, 26 e 27 Febbraio 2014
Manage code with DCVS (Visual Studio Online, GitHub, …)• Back to your IaaS/On Premise installation
• Install Git (Git Bash)cd C:\XAMPP\apache\htdocs
git init
git commit -m "first commit"
git remote add origin https://github.com/marcoparenzan/<repository>.git
git push -u origin master
• Go (again!) back to Azure Mgmt portal• Deployments
• And see that deployment is already running (azure has some hooks that connects to source origins)
#CDays14 – Milano 25, 26 e 27 Febbraio 2014
MySQL, oh my!
• SQL Server has SQL Azure PaaS counterpart…MySQL? It has http://www.cleardb.com/
• Many plan offering• Can connect Azure and have some specific plans for Azure (hosted on Azure)• Ex. Mercurial, free 20Mb starter plan
• Login with ClearDb• Select Plan• Give Database name• Confirm• “Pay”• You obtain the credentials• Server Name/Database name/Username/Password
#CDays14 – Milano 25, 26 e 27 Febbraio 2014
Connect Azure WebSite with ClearDb
• Go to Dashboard | Configuration
• Enable Visual Studio Online Edit “Monaco”
• Dashboard | Edit Visual Studio Online Edit “Monaco”• Or type http://<yoursite>-dev.scm.azurewebsites.net/dev
• Restart site
• Test you app with db
• Now you can “switch” slots and make the dev slot the published one
• Happy WP!
#CDays14 – Milano 25, 26 e 27 Febbraio 2014
Using PaaS as Developer
#CDays14 – Milano 25, 26 e 27 Febbraio 2014
Node.js – First Class Citizen in Azure World
• Azure Web Sites natively have Node installed and supported• Server side developer experience tools/Monaco
• 1st generation mobile services
• Develop Javascript server side
• Just to see something different• Powerful single-threaded web server
• WebApis IO/intensive
• Node.js Visual Studio support/addon for VS2013
• Express.js/MVC framework for Node.js…with Bootstrap!
#CDays14 – Milano 25, 26 e 27 Febbraio 2014
A simple solution
• Data Entry• Acquire Name and Address in two steps and save infos in a simple csv file
• Written in Javascript/Node.js
• Worker• Read the files, decode from google, save them into SQL ….
• Writter in C#/.NET
• DB• A database to store Name, Address, Location (coordinates)
• Written in T-SQL
#CDays14 – Milano 25, 26 e 27 Febbraio 2014
Sessions vs. Horizontal Scalability and Elasticity
• Don’t discuss if sessions are good • You have them
• You have to enable and configure in Express.js
• You are in AzureMany opportunities• Horizontal Scalabilityincrease the number of paritetic instances with copies
of the same app
• Operation: go to the “scale” panel and increase the number of instances
• ElasticityAutomatically increase and decrease instances with metrics (load of processor up to now, polled every 5 minutes)
#CDays14 – Milano 25, 26 e 27 Febbraio 2014
Two questions about scaling
• Does your app works?• Yes
• Does your app scale?• No
• Your app works because of server affinity• Front-end balancer inject a cookie that allow to redirect the subsequent requests
always to the same machine
• Server affinity is not good balancing• Better, per request balancing
• How?• Bring your session out
#CDays14 – Milano 25, 26 e 27 Febbraio 2014
Let your app scale
• First• Disable Server affinity from web.config
<configuration>
<system.webServer>
<httpProtocol>
<customHeaders>
<add name="Arr-Disable-Session-Affinity" value="True" />
• Look! Your app no more works
• You need to share some memory OUTSIDE web site instances
#CDays14 – Milano 25, 26 e 27 Febbraio 2014
Redis Cache
• Performant Key/Value store
• Great scaling
• Goto portal.azure.com
• Create you configuration
• Obtain• Address
• Secret Key
• Configure Node/Express app to store session into Redis
#CDays14 – Milano 25, 26 e 27 Febbraio 2014
Store data into files
• Storing data into files is not so practical in Cloud and Azure
• Usage of on premise API/SMB protocol• You can share a folder from a VM
• But you need authentication, configuration
• You can use a Azure Files, configured into Azure Storage
• But in the same region, only from VM
• Or you can mount a .vhd image with Azure Drive, stored again in storage (you need code)
#CDays14 – Milano 25, 26 e 27 Febbraio 2014
All inside Kudu
• Azure Web Sites• All instances share the same disk image• So if you write file on a folder inside, all instances can view them• Not shareable outside
• Check what’s happen• <youwebsite>.scm.azurewebsites.net
• Kudu Console• CMD• Dir “ENV HOME=D:\Home”
• Data “D:\Home\Data”
• A modern application have to use another kind of storage and you have to write some other code
• If not shareable outside, how can you handle them?
#CDays14 – Milano 25, 26 e 27 Febbraio 2014
Azure WebJobs
• Worker roles• Not public web end point
• “Headless” role
• Run inside VM
• It’s a .NET Console application
• WebJobs are Azure WebSites• They run on the same image
• They can read/write the same disk image
• Store the result in SQL database
#CDays14 – Milano 25, 26 e 27 Febbraio 2014
SQL Databases
• From On Premise SQL Server…
• …to Azure…• VM with SQL Server installed, or….• …SQL Azure!
• SQL Azure• It’s not just SQL Server deployed as SaaS• It’s a new write in search of full compatibility with SQL Server• Not all features are available• Ops…not so much• Dev
• Original one….many things missing• New V12….CLR support, Geography
• Check compatibility!• Use some tools, like Visual Studio Database project• Look: Properties | Target Platform | Microsoft SQL Azure Database (V12)
#CDays14 – Milano 25, 26 e 27 Febbraio 2014
Recap
#CDays14 – Milano 25, 26 e 27 Febbraio 2014
Recap: open the menu, IT as a Service
• “Buy”• SaaS if available
• “Make”• PaaS if possible
• IaaS if needed
• On Premise if really really really really needed
#CDays14 – Milano 25, 26 e 27 Febbraio 2014
Recap: PaaS Azure Web Sites
• The simplest way to access Azure
• Simple scalability and elasticity
• Same tools
• Many possibilities from Ops
• …but better performances if you decide to write some code
Migrare applicazioni web su Azure
Questionario di valutazione:
http://aka.ms/cloudcommunitydays
Grazie della partecipazione
www.slideshare.net/marco.parenzanwww.github.com/marcoparenzan
marco [dot] parenzan [at] live [dot] itwww.innovazionefvg.net
@marco_parenzan
#CDays14 – Milano 25, 26 e 27 Febbraio 2014
Q&A
Tutto il materiale di questa sessione suhttp://www.communitydays.it/
Lascia subito il feedback su questa sessione,potrai essere estratto per i nostri premi!
Seguici suTwitter @CommunityDaysITFacebook http://facebook.com/cdaysit#CDays15
www.slideshare.net/marco.parenzanwww.github.com/marcoparenzanmarco [dot] parenzan [at] live [dot] itwww.innovazionefvg.net@marco_parenzan