-
Ensure that you are logged in to your Windows 10 Virtual Machine using the following credentials:
-
Username: Admin
-
Password: Pa55w.rd
-
-
Observe the Taskbar located at the bottom of your Windows 10 desktop. The Taskbar contains the icons for the common applications we will use in the labs:
-
Microsoft Edge
-
File Explorer
-
Bash on Ubuntu on Windows
-
Windows PowerShell
-
Microsoft Word 2016
Note: You can also find shortcuts to these applications on the Desktop and in the Start Menu.
-
-
On the Taskbar, click the Microsoft Edge icon.
-
In the open browser window, navigate to the Azure Portal (https://portal.azure.com).
-
Enter the email address of your Microsoft account.
-
Click the Next button.
-
Enter the password for your Microsoft account.
-
Click the Sign in button.
-
On the left side of the portal, click the Create a resource link.
-
At the top of the New blade, locate the Search the Marketplace field.
-
Enter the text Cosmos into the search field and press Enter.
-
In the Everything search results blade, select the Azure Cosmos DB result.
-
In the Azure Cosmos DB blade, click the Create button.
-
In the new Azure Cosmos DB blade, perform the following actions:
a. In the ID field, enter a globally unique value.
a. In the API list, select the SQL option.
a. Leave the Subscription field set to its default value.
a. In the Resource group section, select the Create new option.
a. In the Resource group section, enter the value MOD07CSDB into the empty field.
a. In the Location field, select the East US location.
a. Click the Create button.
-
Wait for the creation task to complete before moving on with this lab.
-
On the left side of the portal, click the Resource groups link.
-
In the Resource groups blade, locate and select the MOD07CSDB Resource Group link.
-
In the MOD07CSDB blade, select the Azure Cosmos DB account you recently created.
-
In the Azure Cosmos DB blade, locate and click the Overview link on the left side of the blade.
-
At the top of the Azure Cosmos DB blade, click the Add Collection button.
-
In the Add Collection popup, perform the following actions:
a. In the Database id field, enter the value FinancialClubDatabase.
a. In the Collection id field, enter the value MemberCollection.
a. In the Storage capacity section, select the Fixed (10 GB) option.
a. In the Throughput field, enter thev alue 400.
a. Click the OK button.
-
Wait for the creation of the new database and collection to finish before moving on with this lab.
-
On the left side of the Azure Cosmos DB blade, locate the Settings section and click the Keys link.
-
In the Keys pane, record the values in the URI and Primary Key fields. You will use these values later in this lab.
-
On the left side of the Azure Cosmos DB blade, locate and click the Data Explorer link.
-
In the Data Explorer pane, locate the Collections section and expand the FinancialClubDatabase node.
-
Still within the Collections section, select the MemberCollection node located underneath the FinancialClubDatabase node.
-
Click the New SQL Query button at the top of the Data Explorer pane.
-
In the new Query tab that opened, locate the query editor. Replace the existing query with the following query:
SELECT * FROM coll
-
Click the Execute Query button at the top of the query editor.
-
Within the Collections section, expand the MemberCollection node.
-
Still within the Collections section, select the Documents node located underneath the MemberCollection node.
-
In the new Documents tab that opened, click the New Document button at the top of the tab.
-
In the Documents tab, locate the document editor. Replace the existing document with the following document:
{ "firstName": "Pennington", "lastName": "Oneal", "age": 26, "salary": 90000.00, "company": "Veraq", "isVested": false }
-
Click the Save button at the top of the Documents tab.
-
In the Documents tab, click the New Document button at the top of the tab.
-
In the Documents tab, locate the document editor. Replace the existing document with the following document:
{ "firstName": "Suzanne", "lastName": "Oneal" }
-
Click the Save button at the top of the Documents tab.
-
Click the New SQL Query button at the top of the Data Explorer pane.
-
In the new Query tab that opened, locate the query editor. Replace the existing query with the following query:
SELECT * FROM coll
-
Click the Execute Query button at the top of the query editor.
-
In the query editor, replace the existing query with the following query:
SELECT coll.id, coll.firstName, coll.lastName, coll.isVested FROM coll WHERE IS_DEFINED(coll.isVested)
-
Click the Execute Query button at the top of the query editor.
-
In the query editor, replace the existing query with the following query:
SELECT coll.id, coll.firstName, coll.lastName, coll.age FROM coll WHERE coll.age > 20
-
Click the Execute Query button at the top of the query editor.
-
In the query editor, replace the existing query with the following query:
SELECT VALUE coll.id FROM coll
-
Click the Execute Query button at the top of the query editor.
-
In the query editor, replace the existing query with the following query:
SELECT VALUE { "badgeNumber": SUBSTRING(coll.id, 0, 8), "departmentId": SUBSTRING(coll.id, 9, 4), "fullName": CONCAT(coll.firstName, " ", coll.lastName) } FROM coll
-
Click the Execute Query button at the top of the query editor.
Review: In this exercise, you created a new Cosmos DB account and populated that account with a database, collection, and document.
-
On the left side of the portal, click the Create a resource link.
-
At the top of the New blade, locate the Search the Marketplace field.
-
Enter the text Template Deployment into the search field and press Enter.
-
In the Everything search results blade, select the Template deployment result.
-
In the Template deployment blade, click the Create button.
-
In the Custom deployment blade, click the Build your own template in the editor link.
-
In the Edit template blade, click the Load file link.
-
In the Open file dialog that appears, navigate to the Allfiles (F):\Mod07\Labfiles\Starter folder.
-
Select the api.json file.
-
Click the Open button.
-
Back in the Edit template blade, click the Save button to persist the template.
-
Back in the Custom deployment blade, perform the following actions:
a. Leave the Subscription field set to its default value.
a. In the Resource group section, select the Use existing option.
a. In the Resource group section, select the value MOD07CSDB from the list.
a. In the Terms and Conditions section, select the I agree to the terms and conditions stated above checkbox.
a. Click the Purchase button.
-
Wait for the deployment task to complete before moving on with this lab.
Note: Deployment from source control can take up to ten minutes.
-
On the left side of the portal, click the Resource groups link.
-
In the Resource groups blade, locate and select the MOD07CSDB Resource Group link.
-
In the MOD07CSDB blade, select the Api App you most recently created.
-
In the Api App blade, locate the Settings section and click the Application Settings link.
-
In the Application Settings pane, scroll down and locate the App Settings section. Perform the following actions:
a. Update the value of the CosmosDB:AuthorizationKey setting to the value of the Primary Key field from the Cosmos DB instance you created earlier in this lab.
a. Update the value of the CosmosDB:EndointUrl setting to the value of the Uri field from the Cosmos DB instance you created earlier in this lab.
a. Click the Save button at the top of the pane.
-
In the left-side of the Api App blade, locate and click the Overview link.
-
Click the Restart button at the top of the blade. Wait a couple of minutes for the Web App instance to restart*.
-
Click the Browse button at the top of the blade.
Note: If you click the browse button before the Web App has fully restarted, you may see an error message. Simply refresh your browser until the Web App is running again.
-
In the Swagger UI homepage, click the link to expand the section for the /Get call using the GET HTTP Verb.
-
Locate the Response Messages section. Click the Try it out! button.
-
Observe the results of the request.
-
Back in the Swagger UI homepage, click the link to expand the section for the /Populate call using the POST HTTP Verb.
-
Locate the Parameters section. In the Value field for the options parameter, paste in the following JSON content:
{ "quantity": 50 }
-
Locate the Response Messages section. Click the Try it out! button.
-
Observe the results of the request.
-
Back in the Swagger UI homepage, click the link to expand the section for the /Get call using the GET HTTP Verb.
-
Locate the Response Messages section. Click the Try it out! button.
-
Observe the results of the request.
-
Close the additional browser tab and return to the browser tab with the Azure Portal currently active.
Review: In this exercise, you created a new API App that uses the .NET Core DocumentDB SDK to connect to Azure Cosmos DB and manipulate documents.
-
On the left side of the portal, click the Create a resource link.
-
At the top of the New blade, locate the Search the Marketplace field.
-
Enter the text Search into the search field and press Enter.
-
In the Everything search results blade, select the Azure Search result.
-
In the Azure Search blade, click the Create button.
-
In the New Search Service blade, perform the following actions:
a. In the URL field, enter a globally unique value.
a. Leave the Subscription field set to its default value.
a. In the Resource group section, select the Use existing option.
a. In the Resource group section, locate the dropdown list and select the MOD07CSDB option.
a. In the Location field, select the East US location.
a. Click the Pricing tier option.
a. In the Choose your pricing tier blade, select the Free option and then click the Select button.
a. Click the Create button.
-
Wait for the creation task to complete before moving on with this lab.
-
In the Resource groups blade, locate and select the MOD07CSDB Resource Group link.
-
In the MOD07CSDB blade, select the Azure Search instance you recently created.
-
In the Search Service blade, locate the Settings section and click the Keys link.
-
In the Keys pane, record the value of the PRIMARY ADMIN KEY field. Additionally, record the name of your Azure Search instance. You will use these values later in this lab.
-
On the left side of the portal, click the Resource groups link.
-
In the Resource groups blade, locate and select the MOD07CSDB Resource Group link.
-
In the MOD07CSDB blade, select the Azure Cosmos DB account you recently created.
-
In the Azure Cosmos DB blade, locate the Settings section on the left side of the blade and click the Add Azure Search link.
-
In the Import data blade, select the Search service option to begin configuring the search indexer by performing the following actions:
a. Select the new search instance you created earlier in the lab.
-
The Import data blade will move on to the Data Source option. Continue configuring the search indexer by performing the following actions:
Note: The CosmosDB option should already be selected in the Data Source blade
a. In the Name field, enter the value cosmosdata.
a. In the Database list, select the FinancialClubDatabase option.
a. in the Collection list, select the MemberCollection option.
a. In the Query field, enter the following SQL query:
SELECT coll.id, coll.firstName, coll.lastName, coll.age, coll.salary, coll.company, coll.isVested, coll._ts FROM coll WHERE coll._ts >= @HighWaterMark ORDER BY coll._ts
a. Ensure that the Query results ordered by _ts checkbox is selected.
a. Click the OK button.
-
The Import data blade will move on to the Index option, continue configuring the search indexer by performing the following actions:
a. In the Index name field, enter the value memberindex.
a. In the Key list, select the id option.
a. For the id field in the table, ensure that the Retrievable, Filterable, and Sortable options are selected.
a. For the firstName field in the table, ensure that the Retrievable, Sortable, and Searchable options are selected.
a. For the lastName field in the table, ensure that the Retrievable, Sortable, and Searchable options are selected.
a. For the age field in the table, ensure that the Retrievable, Filterable, Sortable, and Facetable options are selected.
a. For the salary field in the table, ensure that the Retrievable, Filterable, Sortable, and Facetable options are selected.
a. For the company field in the table, ensure that the Retrievable, Facetable, and Searchable options are selected.
a. For the isVested field in the table, ensure that the Retrievable, Filterable, Sortable, Facetable options are selected.
a. Click the OK button.
-
The Import data blade will move on to the Indexer option, continue configuring the search indexer by performing the following actions:
a. In the Name field, enter the value cosmosmemberindexer.
a. In the Schedule section, select the Custom option.
a. In the Interval field, enter the value 5.
a. In the Start time (UTC) field, enter the value 2016-01-01.
a. Click the OK button.
-
Back in the Create Azure Container Instance blade, click the OK button.
-
On the left side of the portal, click the Resource groups link.
-
In the Resource groups blade, locate and select the MOD07CSDB Resource Group link.
-
In the MOD07CSDB blade, select the Api App you most recently created.
-
In the Api App blade, locate the Settings section and click the Application Settings link.
-
In the Application Settings pane, scroll down and locate the App Settings section. Perform the following actions:
a. Update the value of the Search:AccountName setting to the value of the Name of the Azure Search instance you created earlier in this lab.
a. Update the value of the Search:QueryKey setting to the value of the Primary Key field from Azure Search instance you created earlier in this lab.
a. Click the Save button at the top of the pane.
-
In the left-side of the Api App blade, locate and click the Overview link.
-
Click the Restart button at the top of the blade. Wait a couple of minutes for the Web App instance to restart.
-
Click the Browse button at the top of the blade.
Note: If you click the browse button before the Web App has fully restarted, you may see an error message. Simply refresh your browser until the Web App is running again.
-
In the Swagger UI homepage, locate the dropdown list with the content Cosmos DB API v.1.0.0 at the top of the page. Select the Cosmos DB API v.2.0.0 option from the list.
-
Click the link to expand the section for the /Documents/search call using the GET HTTP Verb.
-
Locate the Parameters section. In the Value field for the query parameter, enter the following value:
Oneal
-
Locate the Response Messages section. Click the Try it out! button.
-
Observe the results of the request.
-
Back in the Parameters section. In the Value field for the query parameter, enter the following value:
penn*
-
Locate the Response Messages section. Click the Try it out! button.
-
Observe the results of the request.
-
Close the additional browser tab and return to the browser tab with the Azure Portal currently active.
Review: In this exercise, you created an Azure Search instance that uses an indexer to index the documents in Azure Cosmos DB.
-
At the top of the portal, click the Cloud Shell icon to open a new shell instance.
-
In the Cloud Shell command prompt at the bottom of the portal, type in the following command and press Enter to list all resource groups in the subscription:
az group list
-
Type in the following command and press Enter to delete the MOD07CSDB Resource Group:
az group delete --name MOD07CSDB --no-wait --yes
-
Close the Cloud Shell prompt at the bottom of the portal.
- Close the currently running Microsoft Edge application.
Review: In this exercise, you "cleaned up your subscription" by removing the Resource Groups used in this lab.