In this lab, you will setup your Azure subscription with the required resources needed to perform the Cosmos DB labs. The estimated cost to run these labs if you do it in one sitting is ~$100 USD.
- Azure Paid Subscription
- Azure PowerShell Module
Lab Content Setup
To begin setup, Git clone or download the repo containing these instructions from Github.
- Open Windows Powershell
- Navigate to the folder containing your downloaded copy of the repo
Inside the repo, navigate to the dotnet\setup folder:
To enable the setup scripts to run in your current Powershell session, enter the following:
Set-ExecutionPolicy Unrestricted -Scope Process
This setting will only apply within your current Powershell window.
Many of the labs refer to pre-built code to use as a starting point for the lab instructions. To automatically copy this starter code for the labs into a CosmosLabs folder in your Documents folder run the labCodeSetup.ps1 script:
The starter code for each lab is located inside the templates folder. To use a folder other that Documents\CosmosLabs for your lab code, the files can be copied manually instead.
To begin Azure resource setup, first connect to your Azure account:
Connect-AzAccount -subscription <subscription id>
To create the Azure resources for the labs run the labSetup.ps1 script:
.\labSetup.ps1 -resourceGroupName 'name'
and please choose a
namewhich is likely to be unique i.e.
XXXXXare some random digits.
This script creates resources in the West US region by default. To use another region add -location ‘region name’ to the above command.
This script will fail if the specified resource group already exists, you may want to choose another
namevalue. Alternatively to bypass this failure and create the resources anyway, add -overwriteGroup to the above command.
Some Azure resources can take 10 minutes or more to complete setup so expect the script to run for a while before completing. After the script completes, your account should contain a cosmoslabs resource group with several pre-configured resources:
- Azure CosmosDB Account
- Stream Analytics Job
- Azure Data Factory
- Event Hubs Namespace
Log-in to the Azure Portal
In a new window, sign in to the Azure Portal (https://portal.azure.com).
Once you have logged in, you may be prompted to start a tour of the Azure portal. You can safely skip this step.
Retrieve Account Credentials
The .NET SDK requires credentials to connect to your Azure Cosmos DB account. You will collect and store these credentials for use throughout the lab.
On the left side of the portal, select the Resource groups link.
In the Resource groups blade, locate and select the cosmoslabs Resource Group.
In the cosmoslabs blade, select the Azure Cosmos DB account you recently created.
In the Azure Cosmos DB blade, locate the Settings section and select the Keys link.
In the Keys pane, record the values in the CONNECTION STRING, URI and PRIMARY KEY fields. You will use these values later in this lab.