Skip to content

Commit

Permalink
Updates from Lab #2 and some Lab #1 updates
Browse files Browse the repository at this point in the history
Continued updates to the README.MD for the lab exercises.  This does not include any updates to Lab #3.
  • Loading branch information
pjjohnson committed Oct 30, 2019
1 parent 60049e8 commit 7664614
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 98 deletions.
25 changes: 11 additions & 14 deletions Lab1-MigrateYourData/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -184,11 +184,11 @@ Now that you know our database can be migrated you will use the Migration tool t
8. Choose SQL Server Authentication
9. User: migrateadmin
10. Password: 'AzureMigrateTraining2019#'
11. Press Connect
12. Choose your database and press next
13. Select all tables and press 'Generate SQL script'
11. Select `Connect`
12. Choose your database and select `next`
13. Select all tables and select `Generate SQL script`
14. Once the script is generated, you may review it
15. Press 'Deploy Schema'
15. Select `Deploy Schema`
16. You now have your schema successfully migrated to Azure SQL DB

#### Data Migration
Expand Down Expand Up @@ -234,7 +234,7 @@ By default Azure SQL Databases reject all traffic to them. You were able to run
2. Click on your Azure SQL Server Instance
3. From `Overview`, select `Set server firewall` from the top menu
4. You will see your client IP address listed. You need to create a new rule allowing that IP like this ![SetSQLIP](../images/SetSQLIP.png)
5. Press Save
5. Select `Save`

##### Check your data in SQL

Expand All @@ -255,7 +255,7 @@ You have a shared Linux VM that is simulating the production MongoDB product dat
You can do all this from the Azure Bash Shell

1. Launch a new Azure Command Shell. You can either:
1. Press the shell icon in the Azure Portal, as in the setup for the Cosmos DB
1. Select the shell icon in the Azure Portal, as in the setup for the Cosmos DB
2. Open a new browser tab to: http://shell.azure.com for a full screen experience

2. Download the MongoDB client tools (you can paste into the shell with a right click)
Expand Down Expand Up @@ -283,7 +283,7 @@ You can do all this from the Azure Bash Shell
1. Dump the data from the remote MongoDB with the following Command

1. ```bash
mongodump --host 40.70.205.251 --username=labuser --password=AzureMigrateTraining2019# --db=tailwind --authenticationDatabase=tailwind
mongodump --host 52.175.230.38 --username=labuser --password=AzureMigrateTraining2019# --db=tailwind --authenticationDatabase=tailwind
```

3. Check to see that you successfully dumped the data
Expand Down Expand Up @@ -323,11 +323,10 @@ First check to make sure the Cosmos DB instance was created successfully.
4. Create the following environment variables in that shell

> ```language-bash
> COSMOS_DB_NAME=<Host name from connection string properties>
> COSMOS_USER=<username from connection string properties>
> COSMOS_PWD=<primary password from connection string properties>
> COSMOS_DB_NAME='<Host name from connection string properties>'
> COSMOS_USER='<username from connection string properties>'
> COSMOS_PWD='<primary password from connection string properties>'
> ```


5. Make sure you are still in the /dump/tailwind directory still

Expand All @@ -345,7 +344,7 @@ mongorestore \
--collection inventory
```
8. Go into your Azure Cosmos DB account and click on `Data Explorer`.
9. Press the refresh button next to Collections if you don't see the tailwind collection
9. Select the `refresh` button next to Collections if you don't see the tailwind collection
10. Select the `tailwind` database.
11. Expand the `tailwind` node, expand the `inventory` node, and select `Documents`
12. You should see the inventory item documents are now in Cosmos DB
Expand All @@ -354,11 +353,9 @@ mongorestore \
![cosmospopulated](../images/cosmospopulated.png)
**Congratulations!** You have now successfully moved both a SQL Server Database and a Mongo DB database to the Azure cloud!
## Learn More/Resources
* [Create an Azure Cosmos DB database built to scale](https://docs.microsoft.com/learn/modules/create-cosmos-db-for-scale/?WT.mc_id=msignitethetour-github-mig20)
Expand Down
141 changes: 57 additions & 84 deletions Lab2-ContainerizingApplications/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,71 +19,61 @@ You will need a few things in your environment setup for this lab.
- Azure Container Repository



### Setup 1 - Pull down the source code

The source code for all three projects are in this repo. We will first pull it all down locally in our Azure Bash Shell.
The source code for all three projects are in this repo. You will first pull it all down locally in our Azure Bash Shell.

1. Launch a new Azure Command Shell. You can either:

1. Press the shell icon in the Azure Portal, as in the setup for the Cosmos DB
2. Open a new browser tab to: http://shell.azure.com for a full screen experience

2. Pull down the source code locally. Run the following git command

```bash
git clone https://github.com/chadgms/2019AzureMigrateYourApps
```

3. If you do an ls command you should see the repo on your local shell
![ShowCodeRepo](../images/ShowCodeRepo.png)



### Setup 2 - Create an Azure Container Registry

1. In the Azure portal click on the new resource button
2. Type 'Container Registry' in the search bar - press enter
3. Select Create
3. Select `Create`
4. Fill in properties
1. Registry name: (prefix)acr
2. Resource group: 'Lab-2-xxxxx'
2. Location: default
3. Admin User: Enable
4. SKU: Standard
5. Creation should only take a few minutes, but you can review key features while you are waiting here: https://docs.microsoft.com/en-us/azure/container-registry/container-registry-intro



## Activity 1 - Build your services for docker containers

Now we get into the really exciting stuff! We have an existing code base for our two services and web front end. These steps will compile the code, put them in a docker container and put the container image into the container registry. Typically you would need Docker installed and configured. Azure Container Registry Service can do the build and containerization for us all on the cloud! We just need to point it to our source code.
Now you'll get into the really exciting stuff! There's an existing code base for two services and web front end. In this activity, you will compile the code, put them in a docker container and put the container image into the container registry. Typically you would need Docker installed and configured;however, Azure Container Registry Service can run the build and containerization. You only need to point it to the source code.

### Build the code and deploy to ACR

1. In your Azure Cloud Shell, set an environment variable to the name of your Azure Container Registry (ACR). It is the name you put in the Registry Name property when you created the registry - (prefix)acr. (Do NOT use the full .azurecr.io UNC, only the name)

```bash
MYRG=<your Resource Group name>
MYACR=(prefix)acr
MYID=(prefix)
MYRG='Lab-2-xxxxx'
MYACR='(prefix)acr'
MYID='(prefix)' - the prefix you have been using during this workshop
```



2. Run the following command to build the code and push the product service image to the ACR.

```bash
az acr build -t product-service:latest -r $MYACR ./2019AzureMigrateYourApps/Lab2-ContainerizingApplications/src/product-service
```

3. When finished you can confirm that the container was deployed to ACR in the portal.

1. Click on your resource groups in the portal left navigation bar
2. Click on your resource group
3. Locate your ACR resource type 'Container Register' - Click it
4. Click 'Repositories' in the left navigation
5. You should see your product-service in the repositories list ![DeployContainer](../images/DeployContainer.png)

5. You should see 'product-service' in the repositories list ![DeployContainer](../images/DeployContainer.png)
4. Build the inventory service and frontend containers.****

```
Expand All @@ -93,120 +83,108 @@ Now we get into the really exciting stuff! We have an existing code base for ou
```
az acr build -t frontend-service:latest -r $MYACR ./2019AzureMigrateYourApps/Lab2-ContainerizingApplications/src/frontend
```

5. Verify it exists in the ACR same as before



### Create Web Apps

Now that we have compiled code in containers stored in the registry we now need to deploy them to a compute platform. In this lab we are going to use Azure Web App for Containers, but there are many ways to run containers in Azure. Your instructor should have explored other options. See reference links below for more information.
Now that you have compiled code, you need to deploy them to a compute platform. In this lab, you are going to use Azure Web App for Containers, but there are many ways to run containers in Azure. Your instructor will explore other options. See reference links below for more information.

#### Product Service App

1. Press the create resource button in the Azure portal
2. Search for 'Web app for containers' and press enter
3. Press Create
3. Press `Create`
4. Fill out parameters as follows
1. Basics Tab
1. **Resource Group:** (your resource group)
1. **Resource Group:** use Lab-2-xxxxx
2. **Name:** (prefix)product
3. **Publish:** Docker Image
3. **Publish:** Docker Container
4. **OS:** Linux
5. **Region:** Use the same US region as other labs
5. **Region:** Use 'East US'
6. **Service Plan:** Press Create New
1. Rename to: (prefix)serviceplan
7. **Pricing:** Change Size - > Dev/Test -> B1
2. Docker Tab:
2. From the Docker tab on the top menu:
1. **Options:** Single Container
2. **Image Source:** Azure Container Registry
3. **Registry:** Pick your ACR
4. **Image:** Select the product-service image
5. **<u>Tag</u>:** latest
3. Press Review and Create
4. Press Create
3. Select `Review + create`
4. Select `Create`

#### Inventory Service App

1. Press the create resource button in the Azure portal
1. Select `Create a resource` button in the Azure portal
2. Search for 'Web app for containers' and press enter
3. Press Create
3. Select `Create`
4. Fill out parameters as follows
1. Basics Tab
1. **Resource Group:** (your resource group)
1. **Resource Group:** use Lab-2-xxxxx
2. **Name:** (prefix)inventory
3. **Publish:** Docker Image
4. **OS:** Linux
5. **Region:** <u>Use the same region as the Product Service</u>
6. **Service Plan:** Pick the same service plan that you created for the Product Service. We do not need to create more than one service plan. All the Web Apps can share the compute.
2. Docker Tab:
6. **Service Plan:** Pick the same service plan that you created for the Product Service. You do not need to create more than one service plan. All the Web Apps can share the compute.
2. From the Docker tab on the top menu:
1. **Options:** Single Container
2. **Image Source:** Azure Container Registry
3. **Registry:** Pick your ACR
4. **Image:** Select the inventory-service image
5. **Tag:** latest
3. Press Review and Create
4. Press Create
3. Select `Review + create`
4. Press `Create`
#### Front End App

1. Press the create resource button in the Azure portal
2. Search for 'Web app for containers' and press enter
3. Press Create
4. Fill out parameters as follows
1. Basics Tab
1. **Resource Group:** (your resource group)
1. **Resource Group:** use Lab-2-xxxxx
2. **Name:** (prefix)frontend
3. **Publish:** Docker Image
4. **OS:** Linux
5. **Region:** <u>Use the same region as the Product Service</u>
6. **Service Plan:** Pick the same service plan that you created for the Product Service. We do not need to create more than one service plan. All the Web Apps can share the compute.
6. **Service Plan:** Pick the same service plan that you created for the Product Service. You do not need to create more than one service plan. All the Web Apps can share the compute.
2. Docker Tab:
1. **Options:** Single Container
2. **Image Source:** Azure Container Registry
3. **Registry:** Pick your ACR
4. **Image:** Select the frontend-service image
5. **Tag:** latest
3. Press Review and Create
4. Press Create
3. Select `Review + create`
4. Select `Create`

### Service Configuration

We now have web apps created for all our resources. The last thing we need to do is configure application environment variables like connections strings. When the services start up they can read the environment variables so we can make configurations at runtime.
You now have web apps created for all the resources. The last thing you need to do is configure application environment variables like connections strings. When the services start up they can read the environment variables which enables you to make configurations at runtime.

#### Product Service

The product service uses the NOSQL data that was in the on-premise MogoDB. We successfully migrated that data to Cosmos DB, so that is what we will configure our Product Service for.
The product service uses the NOSQL data that was in the on-premise MongoDB. You successfully migrated that data to Cosmos DB, and now you need to configure the Product Service to use the migrated database.

> **Note:** If you were unable to finish Lab 1 and do not have a CosmosDB with data in it. See the appendix at the end of this lab for a connection string to a shared instance you can use.


##### Get the Cosmos DB connection string

1. Click on resource groups-> (your resource group)

2. Click on your Cosmos DB Account

3. Click on the Connection String option in the left toolbar

1. Select `Resource groups` in the Azure portal, select 'Lab-1-xxxxx' resource group
2. Select your Cosmos DB Account
3. Select `Connection String` in the left-pane menu
4. Copy the Primary Connection String (NOT the primary password)

##### Set the Web App Properties

1. Click on resource groups -> (your resource group)

2. Click on your product service resource of type 'App Service'

3. Click Configuration on the left nav bar

4. Here you will see some default application setting. We will add a few more.

5. Click + New application setting to add each of these NAME/VALUE pairs
1. Select `Resource groups` in the Azure portal, select 'Lab-1-xxxxx' resource group
2. Select your product service resource of type 'App Service'
3. Select `Configuration` on the left-pane menu
4. Here you will see some default application setting, and you will add a few more.
5. Select `+ New application setting` to add each of these NAME/VALUE pairs
1. **Name**: COLLECTION_NAME **Value**: inventory - > Press OK

2. **Name**: DB_CONNECTION_STRING **Value**: (paste in the Cosmos DB connection String)

1. **IMPORTANT:** We need to add the database name 'tailwind' to the connection string. You will see the server address:port and the the /?ssl flag like this:
1. **IMPORTANT:** You need to add the database name 'tailwind' to the connection string. You will see the server address:port and the the /?ssl flag like this:

```
...azure.com:10255/?ssl...
Expand All @@ -221,12 +199,9 @@ The product service uses the NOSQL data that was in the on-premise MogoDB. We s
![cosmosconnectstring](../images/cosmosconnectstring.png)
6. You should have two app settings something like this ![productappsettings](../images/productappsettings.png)
7. Select `Save` from top menu
7. Press Save
**Note**: Connection strings can also be resolved from [Key Vault](https://docs.microsoft.com/en-us/azure/key-vault/) using [Key Vault references](https://docs.microsoft.com/en-us/azure/app-service/app-service-key-vault-references). We are not using Key Vault for this lab, but these are good references to review.
**Note**: Connection strings can also be resolved from [Key Vault](https://docs.microsoft.com/en-us/azure/key-vault/) using [Key Vault references](https://docs.microsoft.com/en-us/azure/app-service/app-service-key-vault-references). You are not using Key Vault for this lab, but these are good references to review.
#### Inventory Service
Expand All @@ -235,18 +210,18 @@ The inventory service needs to be pointed to the SQL Database that now lives in
##### Get the Azure SQL Connection String
1. Click on resource groups -> (your resource group)
2. Click on the tailwind database (resource type: SQL database)
3. Click on connection strings on the left navigation pane
1. Select `Resource groups` in the Azure portal, select 'Lab-1-xxxxx' resource group
2. Select the tailwind database (resource type: SQL database)
3. Select `Connection strings` from the left-pane menu
4. Copy the ADO.NET connection string
##### Set the Web App Properties
1. Click on resource groups -> (your resource group)
2. Click on your inventory service resource of type 'App Service'
3. Click Configuration on the left nav bar
4. Here we will add a Connection String
5. Click + New connection string
1. Select `Resource groups` in the Azure portal, select 'Lab-2-xxxxx' resource group
2. Select on your inventory service resource of type 'App Service'
3. Select `Configuration` on the left-pane menu
4. Here you will add a Connection String
5. Select `+ New connection string`
1. Name: 'InventoryContext'
2. Value: (paste in the SQL connection String>)
3. Update the SQL Connection string:
Expand All @@ -257,37 +232,35 @@ The inventory service needs to be pointed to the SQL Database that now lives in
7. Press Save
#### Front End Web Site
The last thing we need to do is to tell our front end web site the URL's to our web services for product and inventory.
The last thing you need to do is to tell our front end web site the URL's to our web services for product and inventory.
##### Get base URL's
You can get the base URL's for inventory and product services by clicking on their overview page and looking at the URL property on the right hand side.
1. Click on resource groups -> (your resource group)
2. Click on your inventory or product service resource of type 'App Service'
1. Select `Resource groups` in the Azure portal, select 'Lab-2-xxxxx' resource group
2. Select your inventory or product service resource of type 'App Service'
3. Take note / copy the URL
##### Set Front End Web App Properties
We will now set the Front End application settings using the Azure Cli: Copy the below code and replace the base URL placehoders with the URL's of your services.
You will now set the Front End application settings using the Azure Cli: Copy the below code and replace the base URL placehoders with the URL's of your services.
> Note: If you closed the command window you may have lost the values for the initial environment variables we setup. You may need to redefine MYRG and MYID again.
> Note: If you closed the command window you may have lost the values for the initial environment variables you setup, then you need to redefine MYRG and MYID again.
```
az webapp config appsettings set --resource-group $MYRG --name "$MYID"frontend --settings INVENTORY_SERVICE_BASE_URL='<your inventory base url>' PRODUCT_SERVICE_BASE_URL='<your product service base url>'
```
#### Run the App!
That is is it! We are done migrating the data and deploying a modern application through containers. The last thing to do is to run the app and make sure it works! (Note: the web page will render pretty quickly, but the data may take 2-3 minutes to show up. If it takes longer than 3-4 minutes the we should start to debug)
1. Click on resource groups -> (your resource group)
2. Click on your front end service resource of type 'App Service'
3. Click on the URL in the right properties pane
That is is it! You are done migrating the data and deploying a modern application through containers. The last thing to do is to run the app and make sure it works! (Note: the web page will render pretty quickly, but the data may take 2-3 minutes to show up. If it takes longer than 3-4 minutes, then connect with one of the workshop leaders)
1. Select `Resource groups` in the Azure portal, select 'Lab-2-xxxxx' resource group
2. Select your front end service resource of type 'App Service'
3. From the `Overview` menu item, select `URL` in the right properties pane to launch your application
***Your web app should now be live! Congratulations!***
Expand Down

0 comments on commit 7664614

Please sign in to comment.