You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If you don't already have one, create a Cosmos DB account. You can skip this step and use an existing Cosmos DB account.
41
51
@@ -46,15 +56,16 @@ If you don't already have one, create a Cosmos DB account. You can skip this ste
46
56
5. Ensure the **Subscription** and **Resource Group** match the ones you specified when you created your VM in the previous step. Select a **Location** where Cosmos DB is available.
47
57
6. Click **Create**.
48
58
49
-
## Create a collection
59
+
###Create a collection
50
60
51
61
Next, add a data collection in the Cosmos DB account that you can query in later steps.
52
62
53
63
1. Navigate to your newly created Cosmos DB account.
54
64
2. On the **Overview** tab click the **+/Add Collection** button, and an "Add Collection" panel slides out.
55
65
3. Give the collection a database ID, collection ID, select a storage capacity, enter a partition key, enter a throughput value, then click **OK**. For this tutorial, it is sufficient to use "Test" as the database ID and collection ID, select a fixed storage capacity and lowest throughput (400 RU/s).
56
66
57
-
## Grant access
67
+
68
+
### Grant access to the Cosmos DB account access keys
58
69
59
70
This section shows how to grant Windows VM system-assigned managed identity access to the Cosmos DB account access keys. Cosmos DB does not natively support Azure AD authentication. However, you can use a system-assigned managed identity to retrieve a Cosmos DB access key from the Resource Manager, and use the key to access Cosmos DB. In this step, you grant your Windows VM system-assigned managed identity access to the keys to the Cosmos DB account.
60
71
@@ -64,11 +75,15 @@ To grant the Windows VM system-assigned managed identity access to the Cosmos DB
New-AzRoleAssignment -ObjectId $spID -RoleDefinitionName "Cosmos DB Account Reader Role" -Scope "/subscriptions/<mySubscriptionID>/resourceGroups/<myResourceGroup>/providers/Microsoft.DocumentDb/databaseAccounts/<COSMOS DB ACCOUNT NAME>"
66
77
```
67
-
## Get an access token
78
+
## Access data
79
+
80
+
This section shows how to call Azure Resource Manager using an access token for the Windows VM system-assigned managed identity. For the remainder of the tutorial, we will work from the VM we created earlier.
81
+
82
+
You need to install the latest version of [Azure CLI](https://docs.microsoft.com/cli/azure/install-azure-cli) on your Windows VM.
68
83
69
-
This section shows how to get an access token using the Windows VM system-assigned managed identity to call Azure Resource Manager. For the remainder of the tutorial, we will work from the VM we created earlier.
70
84
71
-
You will need to install the latest version of [Azure CLI](https://docs.microsoft.com/cli/azure/install-azure-cli) on your Windows VM.
85
+
86
+
### Get an access token
72
87
73
88
1. In the Azure portal, navigate to **Virtual Machines**, go to your Windows virtual machine, then from the **Overview** page click **Connect** at the top.
74
89
2. Enter in your **Username** and **Password** for which you added when you created the Windows VM.
@@ -93,7 +108,7 @@ You will need to install the latest version of [Azure CLI](https://docs.microsof
93
108
$ArmToken = $content.access_token
94
109
```
95
110
96
-
## Get access keys
111
+
###Get access keys
97
112
98
113
This section shows how to get access keys from Azure Resource Manager to make Cosmos DB calls. Now use PowerShell to call Resource Manager using the access token retrieved in the previous section to retrieve the Cosmos DB account access key. Once we have the access key, we can query Cosmos DB. Be sure to replace the `<SUBSCRIPTION ID>`, `<RESOURCE GROUP>`, and `<COSMOS DB ACCOUNT NAME>` parameter values with your own values. Replace the `<ACCESS TOKEN>` value with the access token you retrieved earlier. If you want to retrieve read/write keys, use key operation type `listKeys`. If you want to retrieve read-only keys, use the key operation type `readonlykeys`:
99
114
@@ -172,6 +187,13 @@ This CLI command returns details about the collection:
0 commit comments