Linux Lift and Shift - Microsoft Cloud Workshop

Microsoft Cloud Workshop Microsoft Cloud Workshop on Dec 01, 2018

In this hands-on lab, you will migrate an on-premises based help desk application called OsTicket, to Azure. This will be a two-phase project to lift-and-shift the application into Azure IaaS and then migrate it to Azure PaaS. The application is Linux based using Apache, PHP and MySQL (LAMP). During the process of these phases, you will ensure zero data loss.

By the end of the hands-on lab you will be better able to configure Linux VMs and VM Scale Sets in Azure for availability, storage, and connectivity. You will also be better prepared to migrate data from on-premises to Azure, establish connectivity between multiple regions and on-premises to Azure. You will also learn how to deploy and scale applications to Azure Web Apps on Linux.

Before the Hands-on Lab

Linux lift and shift
Before the hands-on lab setup guide
December 2018

Information in this document, including URL and other Internet Web site references, is subject to change without notice. Unless otherwise noted, the example companies, organizations, products, domain names, e-mail addresses, logos, people, places, and events depicted herein are fictitious, and no association with any real company, organization, product, domain name, e-mail address, logo, person, place or event is intended or should be inferred. Complying with all applicable copyright laws is the responsibility of the user. Without limiting the rights under copyright, no part of this document may be reproduced, stored in or introduced into a retrieval system, or transmitted in any form or by any means (electronic, mechanical, photocopying, recording, or otherwise), or for any purpose, without the express written permission of Microsoft Corporation.

Microsoft may have patents, patent applications, trademarks, copyrights, or other intellectual property rights covering subject matter in this document. Except as expressly provided in any written license agreement from Microsoft, the furnishing of this document does not give you any license to these patents, trademarks, copyrights, or other intellectual property.

The names of manufacturers, products, or URLs are provided for informational purposes only and Microsoft makes no representations and warranties, either expressed, implied, or statutory, regarding these manufacturers or the use of the products with any Microsoft technologies. The inclusion of a manufacturer or product does not imply endorsement of Microsoft of the manufacturer or product. Links may be provided to third party sites. Such sites are not under the control of Microsoft and Microsoft is not responsible for the contents of any linked site or any link contained in a linked site, or any changes or updates to such sites. Microsoft is not responsible for webcasting or any other form of transmission received from any linked site. Microsoft is providing these links to you only as a convenience, and the inclusion of any link does not imply endorsement of Microsoft of the site or the products contained therein.

© 2018 Microsoft Corporation. All rights reserved.

Microsoft and the trademarks listed at https://www.microsoft.com/en-us/legal/intellectualproperty/Trademarks/Usage/General.aspx are trademarks of the Microsoft group of companies. All other trademarks are property of their respective owners.

Contents

Linux lift and shift before the hands-on lab setup guide

Requirements

  • You must have a working Azure subscription to carry out this hands-on lab step-by-step.

Before the hands-on lab

Duration: 30 Minutes

Task 1: Create a virtual machine to execute the lab

  1. Launch a browser and navigate to https://portal.azure.com. Once prompted, login with your Microsoft Azure credentials. If prompted, choose whether your account is an organization account or just a Microsoft Account.

  2. Click on +Create a resource, and in the search box type in Visual Studio Community 2017 and press enter. Click the Visual Studio Community 2017 image running on Windows Server 2016 and with the latest update.

    The create a resource button is selected and marked 1, In the Everything blade, the search field displays Visual Studio Community 2017 on Windows Server 2016 (x64) and is marked 2. Under Results, Visual Studio Community 2017 (latest release) on Windows Server 2016 (x64) is selected and marked 3.

  3. In the Marketplace solution blade, at the bottom of the page keep the deployment model set to Resource Manager, and click Create.

    Screenshot of the Resource Manager deployment model chosen and the create button.

  4. Set the following configuration on the Basics tab and click Next: Disks >:

    • Subscription: If you have multiple subscriptions choose the subscription to execute your labs in.

    • Resource Group: OPSLABRG

    • Virtual machine name: LABVM

    • Region: Choose the closest Azure region to you

    • Availability options: No infrastructure redundancy required

    • Image: Visual Studio Community 2017 (latest release) on Windows Server 2016 (x64)

    • Size: Standard D2S v3

    • Username: demouser

    • Password: demo@pass123

    • Public inbound ports: Allow selected ports

    • Select inbound ports: RDP

    • Already have a Windows License?: No

    The basics tab is selected, all of the configuration options have been set and the Next Disks button is selected.

  5. Verify the following configurations on the Disks tab and then click Next: Networking >.

    • OS disk type: Premium SSD

    The disks tab is selected, the Premium SSD option is configured and the Next Networking button is selected.

  6. Accept the defaults on the Networking tab and then click Next: Management.

    The networking tab is selected, the default options are selected and the Next Management button is selected.

  7. On the Management tab, turn off Boot diagnostics and Enable auto-shutdown and then click Review + Create.

    The management tab is selected, the Boot Diagnostics and enable auto-shutdown settings have been changed to off and the Review and create button is selected.

  8. After the validation has passed, click the Create button to deploy the virtual machine. The deployment should begin provisioning. It may take 10+ minutes for the virtual machine to complete provisioning.

    The review and create tab is selected, the validation passed message is highlighted and the create button is selected.

    Note: Please wait for the LABVM to be provisioned prior to moving to the next step.

  9. After the deployment completes, navigate to your LABVM and click Connect to establish a new Remote Desktop Session.

    The labvm overview blade is shown with the connect button highlighted.

  10. Depending on your remote desktop protocol client and browser configuration you will either be prompted to open an RDP file, or you will need to download it and then open it separately to connect.

  11. Log in with the credentials specified during creation:

    • User: demouser

    • Password: demo@pass123

  12. You will be presented with a Remote Desktop Connection warning because of a certificate trust issue. Click Yes to continue with the connection.

    The Remote Desktop Connection dialog box displays.

  13. When logging on for the first time you will see a prompt on the right asking about network discovery. Click No.

    A Network Diagnostics prompt displays, asking if you want to find PCs, devices, and content on this network and automatically connect.

  14. Notice that Server Manager opens by default. On the left, click Local Server.

    On the Server Manager menu, Local Server is selected.

  15. On the right side of the pane, click On by IE Enhanced Security Configuration.

    In the Essentials section, IE Enhanced Security Configuration is selected, and set to On.

  16. Change to Off for Administrators and click OK.

    In the Internet Explorer Enhanced Security Configuration dialog box, Administrators is set to Off.

Task 2: Install the MySQL Workbench

  1. While logged into LABVM via remote desktop, open Internet Explorer and navigate to https://dev.mysql.com/get/Downloads/MySQLGUITools/mysql-workbench-community-6.3.10-winx64.msi this will download an executable. After the download is finished, click Run to execute it.

  2. Follow the directions of the installer to complete the installation of MySQL Workbench.

  3. After the installation is complete, reboot the machine.

Task 3: Download hands-on lab step-by-step attendee files

  1. After the reboot has completed, download the zipped hands-on lab step-by-step attendee files by clicking on this link:
    https://cloudworkshop.blob.core.windows.net/linux-lift-shift/MCW-linux-lift-shift.zip.

  2. Extract the downloaded files into the directory C:\HOL.

You should follow all steps provided before performing the Hands-on lab.

Hands-on Lab Guide

Linux lift and shift
Hands-on lab step-by-step
December 2018

Information in this document, including URL and other Internet Web site references, is subject to change without notice. Unless otherwise noted, the example companies, organizations, products, domain names, e-mail addresses, logos, people, places, and events depicted herein are fictitious, and no association with any real company, organization, product, domain name, e-mail address, logo, person, place or event is intended or should be inferred. Complying with all applicable copyright laws is the responsibility of the user. Without limiting the rights under copyright, no part of this document may be reproduced, stored in or introduced into a retrieval system, or transmitted in any form or by any means (electronic, mechanical, photocopying, recording, or otherwise), or for any purpose, without the express written permission of Microsoft Corporation.

Microsoft may have patents, patent applications, trademarks, copyrights, or other intellectual property rights covering subject matter in this document. Except as expressly provided in any written license agreement from Microsoft, the furnishing of this document does not give you any license to these patents, trademarks, copyrights, or other intellectual property.

The names of manufacturers, products, or URLs are provided for informational purposes only and Microsoft makes no representations and warranties, either expressed, implied, or statutory, regarding these manufacturers or the use of the products with any Microsoft technologies. The inclusion of a manufacturer or product does not imply endorsement of Microsoft of the manufacturer or product. Links may be provided to third party sites. Such sites are not under the control of Microsoft and Microsoft is not responsible for the contents of any linked site or any link contained in a linked site, or any changes or updates to such sites. Microsoft is not responsible for webcasting or any other form of transmission received from any linked site. Microsoft is providing these links to you only as a convenience, and the inclusion of any link does not imply endorsement of Microsoft of the site or the products contained therein. © 2018 Microsoft Corporation. All rights reserved.

Microsoft and the trademarks listed at https://www.microsoft.com/en-us/legal/intellectualproperty/Trademarks/Usage/General.aspx are trademarks of the Microsoft group of companies. All other trademarks are property of their respective owners.

Contents

Linux lift and shift hands-on lab step-by-step

Abstract and learning objectives

In this hands-on lab, you will migrate an on-premises based help desk application called OsTicket, to Azure. This will be a two-phase project to lift-and-shift the application into Azure IaaS and then migrate it to Azure PaaS. The application is Linux based using Apache, PHP and MySQL (LAMP). During the process of these phases, you will ensure zero data loss.

By the end of the hands-on lab you will be better able to configure Linux VMs and VM Scale Sets in Azure for availability, storage, and connectivity. You will also be better prepared to migrate data from on-premises to Azure, establish connectivity between multiple regions and on-premises to Azure. You will also learn how to deploy and scale applications to Azure Web Apps on Linux.

Overview

Fabrikam Global Manufacturing & Operations Corporation, based in Japan, provides product design, manufacturing, and repair services of domestic individual or industrial electronics, as well as global support for their customers.

To avoid any impact from restructured support operations, executives decided to migrate on-premises customer support systems into Microsoft Azure. The hope is that running Linux VMs on Azure should enable Fabrikam to lower costs while sustaining or even increasing availability of the application.

  • Phase I: Lift and shift the application from on-premises to Azure IaaS using an auto scaling Virtual Machine Scale Set and a MySQL cluster with 3 nodes.

  • Phase II: Migrate to PaaS using Azure App Services with a Linux Docker Container and Azure Database for MySQL.

Phase I will result in an environment resembling this diagram:

The Phase I diagram has two Resource Groups, which are connected by VNet Peering. The first Resource Group is MySQLVNet, and has MySQL, Bitnami, and Linux. The second Resource Group is OsticketVNet, and has Linux, Apache, PHP, and Osticket.

Phase II will result in an environment resembling this diagram:

The Phase II diagram has /OsTicket with an arrow pointing to a Resource Group containing Linux, Docker, osTicket, a web client, and MySQL.

Requirements

You must have a working Azure subscription to carry out this hands-on Lab step-by-step.

Help references

Description Links
Azure Database for MySQL https://docs.microsoft.com/en-us/azure/mysql/
Azure Database for MySQL https://docs.microsoft.com/en-us/azure/mysql/howto-create-manage-server-portal/
Azure Database for MySQL https://docs.microsoft.com/en-us/azure/mysql/howto-manage-firewall-using-portal/
Connect Azure Web App to Azure Database for MySQL https://docs.microsoft.com/en-us/azure/mysql/howto-connect-webapp/
Azure Virtual Machine Scale Sets https://docs.microsoft.com/en-us/azure/virtual-machine-scale-sets/
Using VM Extensions with Azure Virtual Machine Scale Sets https://docs.microsoft.com/en-us/azure/virtual-machine-scale-sets/virtual-machine-scale-sets-deploy-scaling-app-template/
App Service for Linux https://docs.microsoft.com/en-us/azure/app-service/containers/app-service-linux-intro/
Azure CLI https://docs.microsoft.com/en-us/cli/azure/install-azure-cli/

Exercise 1: Deploy the on-premises OsTicket VM application

Duration: 45 Minutes

In this exercise, you will deploy a VM using an ARM template that will act as the on-premises installation of the OsTicket application. This will consist of a single Ubuntu Linux 16.04-LTS VM with Apache, PHP and MySQL installed (LAMP). This application is a helpdesk management software that you will lift and shift into Azure. There is sample data in the application that will be retained throughout the two phases of the project.

This Resource group for OnPremVNet includes the previously mentioned products.

Task 1: Deploy the OnPremVM

  1. From the Azure portal, click on the Cloud Shell icon on the top navigation. Select Bash (Linux) and, when prompted, create a storage account for your Cloud Shell to use.

    Screenshot of the Launch Cloud shell icon.

  2. Execute the following command to create a resource group that will contain the application:

    Note: You can also specify an alternate region.

    az group create --name OsTicketOnPremRG --location "East US"
    
  3. Execute the following command to deploy the ARM template:

    az group deployment create --name OsTicketOnPremRG --resource-group OsTicketOnPremRG --template-uri "https://cloudworkshop.blob.core.windows.net/linux-lift-shift/onpremvmdeploy.json" 
    
  4. This deployment will take about 5 minutes to complete. Wait until it has been deployed before moving on to the next step.

  5. Once the deployment has completed open the resource group OsTicketOnPremRG and review the deployment.

    In the Resource Group blade, Overview is selected.

  6. Next, click on the onpremvmip Public IP address. Locate the IP address and paste this into a new tab of your web browser. The Support Center OsTicket application should load.

    On the Microsoft Cloud Workshop tab, the Support Center displays.

  7. Click the Sign in link in the upper-right hand corner of the screen.

    Screenshot of the Sign In button.

  8. Locate I'm an agent and click the corresponding sign in here link.

    On the Sign in to Microsoft Cloud Workshop Registration page, the Sign in here link was selected.

  9. At the OsTicket screen, enter the credentials shown below and click Log In:

    1. Username: demouser

    2. Password: demo@pass123

    The osTicket log in webpage displays.

  10. Once logged into the OsTicket system, click My Tickets.

    On the osTicket system page, on the Tickets tab, My Tickets is selected.

  11. On the My Tickets screen, click through to one of the tickets.

    On the osTicket system page, on the Tickets tab, details for a specific ticket display.

  12. Next, click the Users tab and notice the users that are entered into the system.

    On the osTicket system page, the Users tab is selected.

  13. Feel free to create new tickets or new users to add to your dataset.

Task 2: Export the osticket database

  1. From your LABVM, connect to the Azure portal and then open the OsTicketOnPremRG resource group.

    Screenshot of the OsTicketOnPremRG option.

  2. Locate the onpremvmip Public IP address and take note of the address.

    In the Public IP address blade, Overview is selected. Under Essentials, the IP address is selected.

  3. Next on the LABVM click Start and then locate the MySQL Workbench.

    On the Start menu, MySQL Workbench 6.3 CE is selected.

  4. Click the Plus sign next to MySQL Connections on the Workbench.

    The plus sign on the My SQL Collections option is selected.

  5. Enter the following information to configure to connect to your OnPremVM:

    • Connection Name: OnPremVM

    • Connection Method: Standard TCP/IP over SSH

    • SSH Hostname: <enter the Public ip address>:22

    • SSH Username: demouser

    • SSH Password: Click Store in Vault: demo@pass123

    • MySQL Hostname: 127.0.0.1

    • MySQL Server Port: 3306

    • Username: osticket

    • Password: Click Store in Vault: demo@pass123

    The Setup New Connection page displays with fields set to the previously defined settings.

  6. Once configured, click Test Connection.

  7. A pop up will appear with a notice that the SSH Server Fingerprint Missing, click continue.

    The MySQL Workbench popup displays, with the Continue button selected.

  8. If configured correctly, you will receive a message: Successfully made the MySQL Connection. Click OK.

    The MySQL Workbench popup displays, with the OK button selected.

  9. The connection will appear. Double-click to start a session with the MySQL instance running on the OnPremVM.

    Under MySQL Connections, the OnPremVM option is selected.

  10. Once the Workbench loads, in the Navigator pane, click Server Status. Review the details of the server.

    On the MySQL Workbench, under Management, Server Status is selected.

  11. Next, in the Navigator pane, click the osticket database under Schemas and expand to see the tables.

    Under Schemas, osticket is selected.

  12. Locate the ost_user table, right-click and then click Select Rows -- Limit 1000.

    The ost_user table is selected. From its menu, Select Rows - Limit 1000 is selected.

  13. This will launch a query in the Workbench and list all of the users on the system. Notice that these are the same users that you saw in the OsTicket UI.

    In the Workbench, a query displays with same users.

  14. In the Navigator pane to the left, click Data Export.

    Note: You may have to toggle tabs in the pane to Management.

    Under Management, Data Export is selected.

  15. On the Data Export screen, select the osticket schema. Then, select Export to Self-Contained File, and name the file c:\HOL\onpremvm.sql and click Start Export.

    In the Data Export window, under Tables to Export, the check box for osticket is selected. The Export to Self-Contained file is selected, and the address is C:\HOL\onpremvm.sql.

  16. You will get a version mismatch warning, click Continue Anyway.

    In the MySQL Workbench popup, information displays about a version mismatch. The Continue Anyway button is selected.

  17. Once the export has completed, you will receive this message.

    On the data Export page, Object Selection tab, a progress bar shows that the export has completed.

Exercise 2: Migrate to Azure IaaS VM Scale Sets and MySQL cluster

Duration: 90 Minutes

In this exercise, you will deploy the OsTicket application to Azure IaaS. In the first task, you will deploy and configure a MySQL Cluster with multiple nodes. Next, you will restore the database that was exported using MySQL Workbench. After the data tier of your application has been configured you will deploy a Virtual Machine Scale Set. The OsTicket application will be installed on the instances using the Custom Linux Extension and will be self-configuring. The Scale Set will be setup to autoscale and the VMs that spin up will also self-configuring.

The Phase I diagram has two Resource Groups, which are connected by VNet Peering. The first Resource Group is MySQLVNet, and has MySQL, Bitnami, and Linux. The second Resource Group is OsticketVNet, and has Linux, Apache, PHP, and Osticket.

Task 1: Deploy the MySQL HA cluster

  1. From the Azure portal, click on the Cloud Shell icon in the top navigation.

    Screenshot of the Launch Cloud shell icon.

  2. Execute the following command to create a resource group that will contain the MySQL HA environment:

    Note: Ensure you that use the same region as the OsTicket application.

    az group create --name OsTicketMySQLVMRG --location "East US"
    
  3. Execute the following command to deploy the ARM template:

    az group deployment create --name OsTicketMySQLVMRG --resource-group OsTicketMySQLVMRG --template-uri "https://cloudworkshop.blob.core.windows.net/linux-lift-shift/mysqlhadeploy.json" 
    

    Note: The settings that are being deployed as part of the template will be referenced later in the lab.

    • OS User Name: bitnami

    • OS Admin Password: demo@pass123

    • App Database: osticket

    • App Password: demo@pass123

  4. This deployment will take about 15 minutes to complete. Wait until it has been deployed before moving on to the next step.

  5. Once the deployment has completed open the OsTicketMySQLVMRG and review the deployment. Notice that there are three VMs which are a part of a three-node MySQL cluster.

    In the left pane of the Resource Group blade, Overview is selected. In the right pane, under Name, three VMs are circled: osticket0, osticket1, and osticket2.

  6. Locate the osticketip public IP address and take note of the address. Notice that this is attached to the VM osticket0, which is the master node in the cluster.

    In the Public IP address blade, under Essentials, the IP address 52.179.81.179 is circled, and a callout points to the virtual machine name osticket0.

Task 2: Connect to the MySQL cluster and restore the database

  1. On the LABVM, if it isn't still open, click Start and then select MySQL Workbench.

    On the Start menu, MySQL Workbench 6.3 CE is selected.

  2. Click the Plus sign next to MySQL Connections on the Workbench.

    The plus sign next to MySQL Connections is selected.

  3. Enter the following information to configure to connect to your MySQL master node:

    • Connection Name: MySQL Cluster

    • Connection Method: Standard TCP/IP over SSH

    • SSH Hostname: <enter the Public ip address>

    • SSH Username: bitnami

    • SSH Password: Click Store in Vault: demo@pass123

    • MySQL Hostname: 127.0.0.1

    • MySQL Server Port: 3306

    • Username: root

    • Password: Click Store in Vault: demo@pass123

    Fields in the Setup New Connection dialog box are set to the previously defined settings.

  4. Once configured, click Test Connection.

  5. A popup will appear with a notice that the SSH Server Fingerprint Missing, click continue.

    A MySQL Workbench popup displays warning you that the SSH Server Fingerprint is missing. The Continue button is selected.

  6. If the connection is configured correctly, you will receive a message: Successfully made the MySQL Connection. Click OK.

    A MySQL Workbench success popup displays, stating that it successfully made the MySQL connection.

  7. Click OK to save the connection that you just configured.

  8. The Connection will appear. Double-click to start a session with the MySQL Cluster instance running on the Azure IaaS.

    Screenshot of the MySQL Cluster connection.

  9. Once the Workbench loads, click Server Status. Review the details of the cluster. Remember you are connected to the master for the cluster.

    The MySQL Workbench displays. In the left pane, under Management, Server Status is selected.

  10. Click the New Query button.

    On the MySQL Workbench menu, the New Query button is selected.

  11. Execute the following query to show the status of the cluster nodes known as "Slaves". Click the Lighting Bolt to run the query. Notice that the two replication partners appear in the results window as well as their TCP port of 3306.

    SHOW SLAVE HOSTS
    

    On MySQL Workbench, the run query (lightening bolt) icon is selected. A callout points to the Query results, which contains the two replication partners.

  12. Next, click the osticket database under Schemas and expand to see the tables. This time, notice that nothing is in the database yet, since you have not restored it yet from the MySQL data export you created in a previous task.

    Under Schemas, the osticket database is expanded, and Tables is selected.

  13. This is the part of the lift and shift where we will restore the existing database for the application. On the Management tab of the Navigator pane, click the Data Import/Restore button.

    Under Management, Data Import/Restore is selected.

  14. On the Data Import screen, click the Import from Self-Contained File, and then select the C:\HOL\onpremvm.sql data file.

    On the Data Import page, on the Import from Disk tab, the option to Import from self-contained file is selected, and the file location is c:\HOL\ompremvm.sql.

  15. Next, set the Default Target Schema as osticket and click Start Import. This will restore the data from the OnPremVM to the MySQL cluster. Then, in the bottom right-hand corner of the screen, click Start Import.

    On the Default Schema to be Imported To page, the Default Target Schema is set to osticket.

  16. Once the restore is completed, the following screen will appear:

    On the MySQL Cluster Data Import page, on the Import Progress tab, status shows as import completed.

  17. Move back to the Schemas area of the MySQL Workbench, and click the refresh icon.

    Under Schemas, ost_user is selected, and from its right-click menu, Select Rows-Limit 1000 is selected..

  18. The tables of the database now appear since they have been restored. Locate the ost_user table, right-click and then click Select Rows -- Limit 1000.

    The ost_user table is selected. From its menu, Select Rows - Limit 1000 is selected.

  19. This will launch a query in the Workbench and list all the users on the system. Notice that now the data from the application has been lifted and shifted into a MySQL Cluster running in Azure IaaS. The term lift and shift means that there was zero data loss during the move.

    On the Workbench, on the ost_user tab, a callout points to the query results.

Task 3: Deploy the Virtual Machine Scale Set for the OsTicket Application

  1. From the Azure portal, click on the Cloud Shell icon on the top navigation.

    Screenshot of the Launch Cloud shell icon.

  2. Execute the following command to create a resource group that will contain the MySQL HA environment:

    Note: Ensure you that use the same region as the OsTicket application.

    az group create --name OsTicketVMSSRG --location "East US"
    
  3. Execute the following command to deploy the ARM template. This command requires a parameter to be passed to the template. In the example, osticketXX is used. Replace that value with a unique value that is lowercase and less than 10 characters. Just replace the value of XX into any number which is unique. It will take up to 10 minutes to run and complete the command.

    az group deployment create --name OsTicketVMSSRG --resource-group OsTicketVMSSRG --template-uri "https://cloudworkshop.blob.core.windows.net/linux-lift-shift/scalesetdeploy.json" --parameters vmssName=osticketXX
    

    Take note of the credentials for the VMSS:

    • Admin Username: demouser

    • OS Admin Password: demo@pass123

  4. Once the deployment has completed, open the OsTicketVMSSRG and review the deployment.

    In the OsTicketVMSSRG Resource Group blade, in the left pane, Overview is selected. In the right pane, four items display under Name: osticket1 (vm scale set), osticket11lb (load balancer), osticket11pip (public IP address), and osticket11vnet (virtual network).

  5. Open the Virtual Machine Scale Set (it has the same name that you passed in earlier as a parameter). Notice that there are two instances (to start out with), which are a part of a VM Scale Set and that autoscaling has been enabled. After some time, it will be scaled down to only one instance given the lack of traffic to the site.

    In the Virtual Machine Scale Set blade, under Essentials, a callout points to Autoscaling, which is currently On.

  6. Take note of the public IP address.

  7. If you browse to the IP address in a new tab, you will not be able to connect to the webpage. This is due to the lack of connectivity to the MySQL Cluster.

  8. Click the Instances link in Settings.

    Under Settings, Instances is selected.

  9. Here you can take different actions on the Scale Set instances. Click on the instances, and review the information pane.

    Under Name, osticket11_0 has a status of running.

  10. In the information pane, notice the "Latest model applied" information. This is where you can update the image being used for the OS. By selecting the instances and then clicking the update, you can apply system updates to the VMs that are currently running.

    The osticket11_0 information pane displays. A callout points Latest model applied, which is set to Yes.

  11. Click the Scaling link in the Settings menu section of the Scale Set.

    Under Settings, Scaling is selected.

  12. Review the rules for Scale Out and Scale In.

    The rules for scale in and scale out display.

  13. Click the Notify tab on this page, check the Email Administrators and Email co-administrators, and add any additional emails you wish. Also, notice that a Webhook could be entered here. Anytime an event happens related to autoscaling, Azure will send a notification. Click Save to configure.

    On the Notify tab, administrators and co-administrators are both selected to be emailed.

Task 4: Connect the MySQLVNet to the Scale Sets VNet

The MySQL Cluster and the Scale Set are running in isolated VNets. To bring the OsTicket application online, you will need to create a peering between these VNets. This was the reason that both deployments needed to be in the same regions along with performance hit if they were in different regions.

  1. In the Azure portal, click on Virtual Networks followed by MySQLVNet and Peerings.

    In the Virtual networks blade, under Name, MySQL VNet is selected. In the Virtual Network blade, under Settings, Peerings is selected.

  2. Click +Add.

    The Add button is selected in the Virtual Network blade.

  3. Enter the name OSTicketPeering followed by Choose a virtual network. Select the VNet you created with your Scale Set (should follow the pattern of <your-scale-set-name>vnet). Click OK.

    In the Add peering blade, the Name field displays OSTICKETPeering, and the Virtual Network (Choose a virtual network) option is selected. In the Choose a virtual network blade, the osticket11vnet virtual network is selected.

  4. Your peering will appear in the blade as Initiated (you may have to refresh the blade to see this update).

    In the Virtual network blade, a callout points out that OSTICKETPeering now has a peering status of initiated.

  5. In the Azure portal, click on Virtual Networks followed by the name of your Scale Set VNet and Peerings. In the case of the example, the VNet is named osticket11vnet.

    In the Virtual networks blade, under Name, osticket11vnet is selected. In the Virtual Network blade, under Settings, Peerings is selected.

  6. Click +Add.

    the Add button is selected in the Visual network blade.

  7. Enter the name OSTicketPeering followed by Choose a virtual network. Select the VNet that you created when you deployed your MySQL HA cluster (i.e. MySQLVNet). Click OK.

    OSTICKETPeering displays in the Name field of the Add peering blade, and Virtual network, Choose a virtual network is selected. In the Choose virtual network blade, MySQLVNet is selected.

  8. Your peering will appear in the blade as Connected (you may have to refresh the blade to see this update).

    The Add button is selected in the Virtual Network blade.

  9. Immediately, the two networks can see each other, which means the Scale Set will be able to see the MySQL Cluster. Open a new browser tab and attempt to connect to the public IP address of the Scale Set. You should see the Support Center website again.

    The Support Center website displays with two button options: Open a New Ticket, or Check Ticket Status.

  10. Click the Sign in link.

    Screenshot of the Sign in link.

  11. Locate I'm an agent, and click the sign in here link.

    On the Sign in to Microsoft Cloud Workshop page, next to I'm an agent, the Sign in here link is selected.

  12. At the OsTicket screen enter the username and password, and click Log In.

    1. Username: demouser

    2. Password: demo@pass123

    The osTicket log in webpage displays.

  13. Once logged into the OsTicket system, click My Tickets.

    On the osTicket page, tickets tab, My Tickets (4) is selected.

  14. On the My Tickets screen, click through to one of the tickets. Once again, you see that the data from the on-premises installation of the OsTicket system is preserved, which means that you have successfully lifted and shifted the application to Azure IaaS!

    The My tickets page displays the details of a ticket.

Task 5: Export the osticket database from the MySQL cluster

  1. Next, on the LABVM, click Start and then locate the MySQL Workbench.

    On the Start menu, MySQL Workbench 6.3 CE is selected.

  2. Double-click to start a session with the MySQL cluster.

    Screenshot of the MySQL Cluster connection.

  3. In the Navigator pane, on the Management tab, click Data Export.

    Under Management, Data Export is selected.

  4. On the Data Export screen, select the osticket. Then select Export to Self-Contained File, and name the file C:\HOL\mysqlcluster.sql and click Start Export.

    On the Administration - Data Export page, on the Object selection tab, under Tables to Export, osticket is selected. Under Export options, Export to Self-Contained File is selected, and the file location is C:\HOL\mysqlcluster.sql.

  5. You will get a version mismatch warning. Select Continue Anyway.

    A MySQL Workbench warning popup displays letting you know there is a version mismatch. The continue anyway button is selected.

  6. Once the export has completed, you will receive this message.

    On the Administration - Data Export page, on the Export Progress tab, the status shows that export has completed.

Exercise 3: Migrate the OsTicket application from Azure IaaS to PaaS

Duration: 60 Minutes

In this exercise, you will implement Phase II of the migration to Azure. Here you will retire the Azure IaaS implementation and move to Azure App Service and Azure Database for MySQL. The first steps will be to build the MySQL DB and again migrate the data using MySQL Workbench. Then, you will create the Azure Web App and connect it to GitHub repository to download the app using a Docker Container with PHP 7.0.

The Phase II diagram has /OsTicket with an arrow pointing to a Resource Group containing Linux, Docker, osTicket, a web client, and MySQL.

Task 1: Create the MySQL database

  1. From the Azure portal, click on the Cloud Shell icon on the top navigation.

    Screenshot of the Launch Cloud shell icon.

  2. Execute the following command to create a resource group to contain the MySQL DB, using a region of your choice:

    az group create --name OsTicketPaaSRG --location "East US"
    
  3. Execute the following command to create a MySQL Database:

    Note: You must choose a unique name for the MySQL server. Replace osticketsrv01 with a more unique value / name.

    az mysql server create --resource-group OsTicketPaaSRG --name osticketsrv01 --location "East US" --admin-user demouser --admin-password demo@pass123 --sku-name GP_Gen5_8 --storage-size 51200 --ssl-enforcement Disabled
    
  4. Add an open firewall rule to the database by executing the following command. Ensure you replace the server name with the unique value from the previous step.

    az mysql server firewall-rule create --resource-group OsTicketPaaSRG --server-name osticketsrv01 --name Internet --start-ip-address 0.0.0.0 --end-ip-address 255.255.255.255
    
  5. Once the MySQL database has been deployed, locate and open it from the OsTicketPaaSRG resource group using the Azure Portal.

  6. Click Connection Strings.

    Under Settings, Connection strings is selected.

  7. Locate the Web App connection string, and press the Click the copy button.

    The Web App script's copy button is selected.

  8. Open a new notepad window and paste this into a new file to retain this string and more information in the next few steps. Update the script to the following:

    Note: Your hostname is the unique name you chose to name your Azure Database instance.

    Database=osticket; Data Source={host_name}.mysql.database.azure.com; User Id=demouser@(host_name); Password=demo@pass123
    

    In the Notepad window, the Web App Script displays.

  9. Click Overview for the MySQL server.

    On the Azure Database for MySQL Server blade, Overview is selected.

  10. Notice the Server name and Server Admin Login name. You can compare them to the edited connection string in your text file (they should be the same).

    Under Essentials, the Server name and Server admin login name are circled. The Server name is osticketmysql.mysql.database.azure.com, and the login name is demouser@osticketmysql

  11. Scroll down, and notice that there are currently four databases that are running on your server.

    In the Databases section, MySQL databases hsa a number 4.

Task 2: Restore the osticket database to MySQL PaaS

  1. On the LABVM, click Start and then launch MySQL Workbench.

    On the Start menu, MySQL Workbench 6.3 CE is selected.

  2. Click the Plus sign next to MySQL Connections on the Workbench.

    The plus sign next to MySQL Connections is selected.

  3. Enter the following information to configure to connect to your Server:

    • Connection Name: <enter your MySQL Server DNS Name -- found in the connection string >

    • Connection Method: Standard TCP/IP

    • MySQL Hostname: <enter your MySQL Server DNS Name -- found in the connection string >

    • MySQL Server Port: 3306

    • Username: <enter your user name -- found in the connection string>

    • Password: Click Store in Vault: demo@pass123

    Fields in the Setup New Connection dialog box are set to the previously defined settings.

  4. Once the connection is configured, click the Test Connection Button.

    Screenshot of the Test Connection button.

  5. If the connection is configured correctly, you will receive a message: Successfully made the MySQL Connection. Click OK.

    A MySQL Workbench success popup displays, informing you that the MySQL connection was successfully made.

  6. Click OK to save the connection that you just configured.

  7. The new connection will appear. Double-click it to start a session with the MySQL database server running on the Azure PaaS.

    Screenshot of the Connection option.

  8. Once the Workbench loads, click Server Status. Review the details of the MySQL PaaS Server.

    On the MySQL Workbench, under Management, Server Status is selected. In the right pane, details for osticketmysql.mysql.database.azure.com display.

  9. This is the part of the lift and shift where we will restore the existing database for the application. Click the Data Import/Restore button.

    Under Management, Data Import/Restore is selected.

  10. On the Data Import screen, click the Import from Self-Contained File, and select the c:\HOL\mysqlcluster.sql data file.

    On the Data Import page, on the Import from Disk tab, under Import options, Import from Self-Contained File is selected, and the location is C:\HOL\mysqlcluster.sql.

  11. In the Default Schema to be Imported To section, click New.

    On the Data Import page, on the Import from Disk tab, the New button is selected.

  12. In the Create Schema dialog, type osticket and click OK.

    Name of schema to create field, osticket is typed.

  13. MySQL Workbench will create the schema (database), on the server for you and select it as the Default Target Schema for the restore.

    The Default Target Schema field is set to osticket.

  14. Click Start Import after reviewing the screen.

    On the Data Import page, on the Import from Disk tab, the Start Import button is selected.

  15. Once the restore is completed, the following screen will appear.

    On the Data Import page, Import Progress tab, the status shows as import completed.

  16. Navigate back to the Schemas tab in the Navigator pane of the MySQL Workbench, and click the Refresh icon.

    Under Schemas, both osticket and the refresh icon are selected.

  17. The tables of the database now appear since they have been restored. Locate the ost_user table in the osticket database. Right-click it, and click Select Rows -- Limit 1000.

    In the List of database tables, ost_user is selected, and from its right-click menu, Select Rows - Limit 1000 is selected.

  18. This will launch a query in the Workbench and list all of the users on the system. The data from the application has been lifted and shifted into a MySQL server running in Azure PaaS. This means there was zero data loss from the move to PaaS.

    On the ost_user tab, the query displays in the pane above, and results display in the Results Grid below.

  19. Move back to the Azure portal, and click Overview for the Azure Database for MySQL Server instance you created earlier.

    On the Azure Database for MySQL server blade, Overview is selected.

  20. Scroll down and notice now that there are five databases and the addition of the osticket.

    In th eDatabases section, under MySQL databases, the number 5 now displays. Under Name, the following five databases are listed: information_schema, mysql, osticket, performance_schema, and sys.

Task 3: Create the Web App

  1. From the Azure portal, click the Cloud Shell icon in the top navigation menu.

    Screenshot of the Launch Cloud shell icon.

  2. Execute the following command to create a Linux-based App Service Plan for the new web app, using the SAME region where you created your Azure Database for MySQL server instance in the previous task.

    az appservice plan create -n OsTicket -g OsTicketPaaSRG --is-linux -l "East US" --sku S1 --number-of-workers 1
    
  3. Execute the following command to create a new web app configured for PHP 7.0 inside of the new App Service Plan. The name of the web app (the value after -n) must be unique, so specify some numbers at the end to make it a more unique value. Example osticketsystem999 or osticketsystem87876.

    az webapp create -n osticketsystem -g OsTicketPaaSRG -p OsTicket -r "php|7.0"
    
  4. Once the deployment has completed, open the OsTicketPaaSRG resource group. Notice there are now three objects: MySQL database, Linux App Service Plan and the Web App.

    On the Resource group blade, Overview is selected. Under Essentials, a callout points to the OsTicket App Service plan.

Task 4: Configure the OsTicket Web App

  1. Open the Web App using the Azure portal. Notice the details of the application including the URL.

    On the App Service blade, Overview is selected. Under Essentials, a callout points to the URL live link http://osticketsystem.azurewebsites.net.

  2. If you click the URL, you will get a Forbidden error from the server. This is because no application has yet been deployed.

  3. In the Azure portal in your web app blade, click Application settings in the Settings menu area.

    Under Settings, Application settings is selected.

  4. Locate the Connection Strings section. Click the +Add new connection string then enter a new connection string name of osticket, copy the data source string from your connection sting into the value area from notepad. Select MySQL in the dropdown list next to the string. Click Save.

    Under Connection strings, the osticket connection string displays.

  5. Open a new browser tab and connect to https://github.com/opsgility/osTicket. This is a public repository for the OsTicket software. Sign in to your personal GitHub account or create a new one.

    On the GitHub webpage, a code tab displays.

  6. On this page locate and then click the Fork button.

    Screenshot of the Fork button.

  7. If prompted, select your personal account when prompted with "Where should we fork this repository?"

    Under Forking opsgility/osticket, a refresh button displays.

  8. After the repository is forked to your GitHub account, scroll down and locate the include folder and click it.

    In a list of folders, the Include folder is selected..

  9. Once in the include folder, scroll down and locate the file named ost-config.php.

    In a list of files, ost-config.php is selected.

  10. The file will open in the browser. Click the Pencil icon to edit this file.

    Screenshot of the Pencil (edit) icon.

  11. The file will open in an editor. Scroll down to the Database Options area of the file. Update the text in this file with your MySQL database settings from your notepad file. The DBHOST name and the DBUSER should be updated. See below for the before and after comparison.

    Before:

    The configuration options in ost-config.php.

    After:

    The configuration options in ost-config.php after the edit.

  12. Once you have updated the text, scroll down, name your commit and click Commit changes.

    The text field under Commit changes reads,

  13. Move back to the Azure portal and, in the Web App blade, click Deployment center in the Deployment menu area.

    Under Deployment, Deployment center is selected.

  14. Select GitHub, and then click the Authorize button and follow the prompts to connect your Github account with your Azure subscription.

    Screenshot of the deployment center with the GitHub deployment option selected and authorization button selected.

  15. Once authorized, select Github and choose Continue.

    Screenshot of the deployment center source control step with the GitHub deployment option selected and continue button selected.

  16. On the build provider step, choose App Service Kudu build server and select Continue.

    Screenshot of the deployment center build provider step with the App Service Kudu build server option selected and continue button selected.

  17. On the configure step, choose your organization or Github account, then select the osticket repository and the master branch.

    Screenshot of the deployment center configure step with the organization option configured, the repository set to osticket, the branch set to master and continue button selected.

  18. The OsTicket application will be downloaded from the GitHub account. First, it will show as Pending and then Active. You may need to refresh the view to see it.

    Screenshot of the deployment status showing pending.

    Screenshot of the deployment status showing success.

  19. Navigate back to the Overview page of your Web App, and then select the URL for the Web App.

    The Web App URL http://osticketsystem.azurewebsites.net displays.

  20. Immediately, the Web App will load. You should see the Support Center website again.

    The Support Center website displays with two button options: Open a New Ticket, or Check Ticket Status.

  21. Click the Sign in link.

    Screenshot of the Sign in link.

  22. Locate I'm an agent and click the sign in here link.

    On the Sign in to Microsoft Cloud Workshop page, next to I'm an agent, the link to sign in here is selected.

  23. At the OsTicket screen, enter the username and password and click Log In.

    1. Username: demouser

    2. Password: demo@pass123

    The osTicket log in webpage displays.

  24. Once logged into the OsTicket system, click My Tickets.

    On the osTicket page, tickets tab, My Tickets (4) is selected.

  25. On the My Tickets screen, click through to one of the tickets. Once again, you see that the data from the IaaS installation of the OsTicket system is preserved which means that you have successfully lifted and shifted the application to Azure PaaS!

After the hands-on lab

Duration: 10 minutes

After you have successfully completed the Linux Lift & Shift Azure hands-on lab step-by-step, you will want to delete the Resource Groups. This will free up your subscription from future charges.

  • OPSLABRG

  • OsTicketMySQLVMRG

  • OsTicketOnPremRG

  • OsTicketPaaSRG

  • OsTicketVMSSRG

You should follow all steps provided after attending the Hands-on lab.

Attribution

This content was originally posted here:
https://github.com/Microsoft/MCW-Linux-Lift-and-Shift

License

This content is licensed with the MIT License license.

MIT License

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE