Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix the screenshot #36

Open
wants to merge 21 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
318f2de
Update Module3-Migrating MongoDB Apps to Azure Cosmos DB(Mongo API).MD
GhumanNavneet Jan 17, 2018
5569766
Update Module2-Migrating MongoDB Apps to Azure Cosmos DB(Mongo API).MD
GhumanNavneet Jan 17, 2018
39c419b
Add files via upload
GhumanNavneet Jan 19, 2018
aea04ec
Delete fnxinfo.jpg
GhumanNavneet Jan 19, 2018
06b843c
Add files via upload
GhumanNavneet Jan 19, 2018
9005f83
Add files via upload
GhumanNavneet Jan 19, 2018
ec699a5
Delete Integrate.jpg
GhumanNavneet Jan 19, 2018
39c1b6a
Add files via upload
GhumanNavneet Jan 19, 2018
9b34117
Update Module2-Migrating MongoDB Apps to Azure Cosmos DB(Mongo API).MD
GhumanNavneet Jan 19, 2018
38891bb
Update Module2-Migrating MongoDB Apps to Azure Cosmos DB(Mongo API).MD
GhumanNavneet Mar 2, 2018
8059a6c
Update Module2-Migrating MongoDB Apps to Azure Cosmos DB(Mongo API).MD
GhumanNavneet Mar 2, 2018
0fd1d4b
Update Module2-Migrating MongoDB Apps to Azure Cosmos DB(Mongo API).MD
GhumanNavneet Mar 2, 2018
b775139
Update Module2-Migrating MongoDB Apps to Azure Cosmos DB(Mongo API).MD
GhumanNavneet Mar 2, 2018
f0f47f8
Update azuredeploy.json
GhumanNavneet Mar 2, 2018
8ab5240
Update Module3-Migrating MongoDB Apps to Azure Cosmos DB(Mongo API).MD
GhumanNavneet Mar 2, 2018
96ee73a
Update Module0-Getting Started.MD
GhumanNavneet Apr 24, 2018
ee9ac94
Delete jumpvm1.jpg
GhumanNavneet Apr 24, 2018
6d6f5ca
Delete cosmoskeyandurl.jpg
GhumanNavneet Apr 24, 2018
b6277ee
Add files via upload
GhumanNavneet Apr 24, 2018
7b737b3
Delete cosmoskeyandurl.jpg
GhumanNavneet Apr 24, 2018
8c3ff4d
Add files via upload
GhumanNavneet Apr 24, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion challenges/Module0-Getting Started.MD
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
In this lab, you will be deploying pre-requisite infrastructure which is required for CosmosDB Hackfest.
#### Prerequisites
* Windows or a Mac machine with HTML5 supported browser such as Microsoft Edge, Internet Explorer, Chrome or Firefox.
* You should have registered in the training portal https://azuretraining.spektrasystems.com and received the confirmation message with the credentials to login to the Azure portal.
* You should have registered in the training portal http://experience-azure-mgmt.azurewebsites.net and received the confirmation message with the credentials to login to the Azure portal.

<img src="images/module.jpg"/><br/>
#### Time Estimate
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# Module 3: Migrate MongoDB Application to Azure Cosmos DB(SQL API)
## Access Cosmos DB account with SQL API (created in Module-1)
1. **Launch** a **browser** and navigate to https://portal.azure.com. **Login** with your **Microsoft Azure** credentials.<br/>
2. **Click** on **Resource Group** provided which contains the all the resources, click on created **Azure Cosmos DB account**(with SQL API) under **Overview** tab.<br/>
2. **Click** on **Resource Group** provided which contains all the resources, click on created **Azure Cosmos DB account**(with SQL API) under **Overview** tab.<br/>
<img src="images/sqlcosmos.jpg"/><br/>
3. **Click** on **Keys** option present under Cosmos DB Account blade, and copy **URI** and **PRIMARY KEY**.<br/>
<img src="images/sqlkey.jpg"/><br/>
4. **Go** back to **Visual Studio Code** IDE and paste the **URI** value against **DOCUMENT_DB_ENDPOINT**, **PRIMARY KEY** against **DOCUMENT_DB_PRIMARYKEY**, **DOCUMENT_DB_DATABASE** and change the **API_MODE** to **SQL** in the **config.js**.<br/>
4. **Go** back to **Visual Studio Code** IDE and paste the **URI** value against **DOCUMENT_DB_ENDPOINT**, **PRIMARY KEY** against **DOCUMENT_DB_PRIMARYKEY**, **DOCUMENT_DB_DATABASE** as **contosoairdb3** and change the **API_MODE** to **SQL** in the **config.js**.<br/>

5. **Navigate** back to the Azure Portal's Resource groups option present in the favourites menu on the left side panel and select the **resource group** and click on **Azure Cosmos DB Account** then, click on **Replicate data globally** option present under **SETTINGS** section in **Cosmos DB Account** blade.<br/>
5. **Navigate** back to the Azure Portal's Resource groups option present in the favourites menu on the left side panel and select the created **resource group** and click on **Azure Cosmos DB Account** then, click on **Replicate data globally** option present under **SETTINGS** section in **Cosmos DB Account** blade.<br/>

6. Copy the **WRITE REGION** and paste it against **DOCUMENT_DB_PREFERRED_REGION** in **config.js** file which is already opened in **Visual Studio Code** IDE and save this file.<br/>
<img src="images/sqlconfig.jpg"/><br/>
Expand Down Expand Up @@ -37,10 +37,72 @@ ng serve
<img src="images/sqldataexplore.jpg"/><br/>

## Launch the Application
1. Copy the **localhost URL** [http://localhost:4200](http://localhost:4200) from the **terminal** and paste it in **Web Browser** and press enter. There's a shortcut created for your already on desktop for this, you can open website using that as well.<br/>
1. Copy the **localhost URL** [http://localhost:4200](http://localhost:4200) from the **here** and paste it in **Web Browser** and press enter. There's a shortcut created for your already on desktop for this, you can open website using that as well.<br/>
1. You will see the **sign-up** page. You need to **login** to App using your **Microsoft Account**(formerly live-id). If you do not have a live-id, you can create one by following instructions given on page.<br/>
<img src="images/signup.jpg"/><br/>
1. Once you get login, you will be redirected to **ContosoAir app**.<br/>
<img src="images/contoso1.jpg"/><br/>
1. Enter **Departure date** and **Return date** in **YYYY-MM-DD** format and click **Find Flights** button.<br/>
<img src="images/contosoapp.jpg"/><br/>

### Create a function with Deal Data

> _Let's create an Azure Function to retrieve data of flight deals._

1. Go to **Resource groups** option present in the favourites menu on the left side panel and select the resource group **<inject story-id="story://Content-Private/content/dfd/SP-GDA/gdaexpericence1/story_a_gda_using_cosmosdb" key="myResourceGroupName"/>** and click on Azure Function named **<inject story-id="story://Content-Private/content/dfd/SP-GDA/gdaexpericence1/story_a_gda_using_cosmosdb" key="azureFunctionName"/>**.<br/>
2. However over the **Functions** under **Functions Apps** and click on **+ sign** besides **Functions**.<br/>
3. Now, click on the **Custom function** link present at the bottom of the page.<br/>
<img src="images/GetStartedOnYourOwn.jpg"/><br/>
4. Click on **C#** template available in **HTTP trigger** section and name the function as "**FetchDealsData**" in **Name** textbox and click **Create** button.<br/>
<img src="images/httptrigger.jpg"/><br/>
<img src="images/httpvalue.jpg"/><br/>
5. A function with sample default code would get created. Now, replace the sample default code with the code snippet given below.<br/>

```c#
using System.Net;
using System.Linq;

public static HttpResponseMessage Run(HttpRequestMessage req, TraceWriter log, IEnumerable<dynamic> SelectDealsData)
{
return req.CreateResponse(HttpStatusCode.OK, SelectDealsData);
}
```

> **NOTE:**
> In above code snippet, **IEnumerable&lt;dynamic> SelectDealsData** is a parameter used to fetch the list of **DealsData** collection from Cosmos DB. This method returns the result fetched from Cosmos DB along with **HttpStatusCode** with the help of **CreateResponse** method.<br/>
6. Click on **Save** button.<br/>
7. Now, click on the **Integrate** option listed in **"FetchDealsData"** function in the **Function Apps** blade.<br/>
8. Under **Inputs** section, click on **+ New Input** and select **Azure Cosmos DB** then click **Select** button at the bottom of page.<br/>
<img src="images/Integrate.jpg"/><br/>
8. Enter **Document parameter name** as **SelectDealsData**, **Database name** as **contosoairdb** and **Collection name** as **DealsCollection** in respective textboxes.<br/>
9. Copy the **SQL query** given below and paste it into **SQL Query (optional)** textbox.<br/>

```sql
select c.id, c.fromName, c.fromCode, c.toName, c.toCode, c.price, c.departTime, c.arrivalTime, c.hours, c.stops, c.since from c
```

> **NOTE:** Above **SQL query** is responsible to get deals details from **DealsCollection** available in Cosmos DB like id, from name, from code, to name, to code, price, depart time, arrival time, hours, stops, since. (Ignore non-mandatory fields)

![](image/SqlQuery.jpg)

10. To enter **Cosmos DB account connection,** click on the **new** link given beside **Cosmos DB account connection** textbox.<br/>
11. You will be redirected to **Cosmos DB Account blade**, select the **MongoDB DB Account** as shown below.<br/>
<img src="images/selectmongodocdb.jpg"/><br/>
12. Now, click **Save** button ![](img/save.jpg) button.<br/>
13. To check whether the function is integrated, click on **FetchDealsData** function present under **AureFunctionForDeals** function app blade and click on **Test** option present at the right most corner.<br/>
<img src="images/file2.jpg"/><br/>
14. Select **HTTP method** as **GET** from the dropdown. Then click **Run** button at the bottom.
<img src="images/runfxn.jpg"/><br/>
15. Status **200 Ok** will be displayed once the test is completed which signifies that the function is integrated successfully.<br/>
<img src="images/status200.jpg"/><br/>

> _Here you go! You have successfully created Azure Function to_ _retrieve flight deals_ _data from_ **Cosmos DB**_._

16. In the **Functions Apps** blade, click on **FetchDealsData**.<br/>
17. You will get navigated to function and will find **</> Get function URL** link in the top right corner of the page. Click on the link <img src="images/getFunctn.jpg"/><br/>
18. On clicking **</> Get function URL** you will get a popup window with a URL.<br/>
<img src="images/getfxnurl.jpg"/><br/>
19. Click on **Copy** ![](img/Copy.jpg) icon to copy the given URL and paste it against **AZURE\_FUNCTION\_DEALS\_URL:** variable in **config.js file** opened in **Visual Studio 2017** IDE and save the file.

> _Awesome, you have created Azure Function for Deals data and integrated with Cosmos DB._

Binary file modified challenges/images/Integrate.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified challenges/images/cosmoskeyandurl.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified challenges/images/fnxinfo.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added challenges/images/inputs.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added challenges/images/japanreplication.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified challenges/images/jumpvm1.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion template/azuredeploy.json
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@
},
"properties": {
"hardwareProfile": {
"vmSize": "Standard_A2_v2"
"vmSize": "Standard_DS2_v2"
},
"osProfile": {
"computerName": "[parameters('powerBIVirtualMachineName')]",
Expand Down