-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of https://github.com/solliancenet/microsoft-lear…
- Loading branch information
Showing
17 changed files
with
1,971 additions
and
1,822 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,9 +18,9 @@ Azure Cosmos DB is a cloud-based NoSQL database service that supports multiple A | |
|
||
1. In a new web browser window or tab, navigate to the Azure portal (``portal.azure.com``). | ||
|
||
2. Sign into the portal using the Microsoft credentials associated with your subscription. | ||
1. Sign into the portal using the Microsoft credentials associated with your subscription. | ||
|
||
3. Select **+ Create a resource**, search for *Cosmos DB*, and then create a new **Azure Cosmos DB for NoSQL** account resource with the following settings, leaving all remaining settings to their default values: | ||
1. Select **+ Create a resource**, search for *Cosmos DB*, and then create a new **Azure Cosmos DB for NoSQL** account resource with the following settings, leaving all remaining settings to their default values: | ||
|
||
| **Setting** | **Value** | | ||
| ---: | :--- | | ||
|
@@ -33,9 +33,15 @@ Azure Cosmos DB is a cloud-based NoSQL database service that supports multiple A | |
|
||
> 📝 Your lab environments may have restrictions preventing you from creating a new resource group. If that is the case, use the existing pre-created resource group. | ||
4. Wait for the deployment task to complete before continuing with this task. | ||
1. Wait for the deployment task to complete before continuing with this task. | ||
|
||
5. Keep the browser tab open for the next step. | ||
1. Go to the newly created **Azure Cosmos DB** account resource and navigate to the **Keys** pane. | ||
|
||
1. This pane contains the connection details and credentials necessary to connect to the account from the SDK. Specifically: | ||
|
||
1. Copy the **URI** field and save it in a text editor for later. You will use this **endpoint** value later in this exercise. | ||
|
||
1. Keep the browser tab open for the next step. | ||
|
||
## Provide your user identity the Cosmos DB Built-in Data Contributor RBAC role | ||
|
||
|
@@ -47,34 +53,26 @@ As the final task in this exercise, you will grant your Microsoft Entra ID user | |
|
||
![The Cloud Shell icon is highlighted on the Azure portal's toolbar.](media/azure-portal-toolbar-cloud-shell.png) | ||
|
||
2. At the Cloud Shell prompt, ensure your exercise subscription is used for subsequent commands by running `az account set -s <SUBSCRIPTION_ID>`, replacing the `<SUBSCRIPTION_ID>` placeholder token with the id of the subscription you are using for this exercise. | ||
|
||
3. Before assigning your account to the **Cosmos DB Built-in Data Contributor** RBAC role, you must retrieve your Entra ID user identity object ID using the Azure CLI. Execute the following command a the Cloud Shell prompt, replacing the `<USER_PRINCIPAL_NAME>` with your user principal name (e.g., an email address like `[email protected]`). | ||
|
||
```azurecli | ||
az ad user show --id <USER_PRINCIPAL_NAME> --query id --output tsv | ||
``` | ||
The above command returns object ID associated with your user identity. | ||
1. At the Cloud Shell prompt, ensure your exercise subscription is used for subsequent commands by running `az account set -s <SUBSCRIPTION_ID>`, replacing the `<SUBSCRIPTION_ID>` placeholder token with the id of the subscription you are using for this exercise. | ||
|
||
4. Copy the output of the above command for use as the `<PRINCIPAL_OBJECT_ID>` token in the `az cosmosdb sql role assignment create` command below. | ||
1. Copy the output of the above command for use as the `<PRINCIPAL_OBJECT_ID>` token in the `az cosmosdb sql role assignment create` command below. | ||
|
||
5. Next, you will retrieve the definition id of the **Cosmos DB Built-in Data Contributor** role. Run the following command, ensuring you replace the `<RESOURCE_GROUP_NAME>` and `<COSMOS_DB_ACCOUNT_NAME>` tokens. | ||
1. Next, you will retrieve the definition id of the **Cosmos DB Built-in Data Contributor** role. Run the following command, ensuring you replace the `<RESOURCE_GROUP_NAME>` and `<COSMOS_DB_ACCOUNT_NAME>` tokens. | ||
|
||
```azurecli | ||
```bash | ||
az cosmosdb sql role definition list --resource-group "<RESOURCE_GROUP_NAME>" --account-name "<COSMOS_DB_ACCOUNT_NAME>" | ||
``` | ||
|
||
Review the output and locate the role definition named **Cosmos DB Built-in Data Contributor**. The output contains the unique identifier of the role definition in the `name` property. Record this value as it is required to use in the assignment step later in the next step. | ||
|
||
6. You are now ready to assign yourself to the **Cosmos DB Built-in Data Contributor** role definition. Enter the following command at the prompt, making sure to replace the `<RESOURCE_GROUP_NAME>`, `<COSMOS_DB_ACCOUNT_NAME>`, and `<PRINCIPAL_OBJECT_ID>` tokens. | ||
1. You are now ready to assign yourself to the **Cosmos DB Built-in Data Contributor** role definition. Enter the following command at the prompt, making sure to replace the `<RESOURCE_GROUP_NAME>` and `<COSMOS_DB_ACCOUNT_NAME>` tokens. | ||
|
||
> 📝 In the command below, the `role-definition-id` is set to `00000000-0000-0000-0000-000000000002`, which is the default value for the **Cosmos DB Built-in Data Contributor** role definition. If the value you retrieved from the `az cosmosdb sql role definition list` command differs, replace the value in the command below before execution. | ||
> 📝 In the command below, the `role-definition-id` is set to `00000000-0000-0000-0000-000000000002`, which is the default value for the **Cosmos DB Built-in Data Contributor** role definition. If the value you retrieved from the `az cosmosdb sql role definition list` command differs, replace the value in the command below before execution. The `az ad signed-in-user show` command retrieves the object ID of the signed-in Entra ID user. | ||
|
||
```azurecli | ||
az cosmosdb sql role assignment create --resource-group "<RESOURCE_GROUP_NAME>" --account-name "<COSMOS_DB_ACCOUNT_NAME>" --role-definition-id "00000000-0000-0000-0000-000000000002" --principal-id "<PRINCIPAL_OBJECT_ID>" --scope "/" | ||
```bash | ||
az cosmosdb sql role assignment create --resource-group "<RESOURCE_GROUP_NAME>" --account-name "<COSMOS_DB_ACCOUNT_NAME>" --role-definition-id "00000000-0000-0000-0000-000000000002" --principal-id $(az ad signed-in-user show --query id -o tsv) --scope "/" | ||
``` | ||
|
||
7. When the command finishes running, you will be able to run code locally to insert interact with data stored into the your Cosmos DB NoSQL database. | ||
1. When the command finishes running, you will be able to run code locally to insert interact with data stored into the your Cosmos DB NoSQL database. | ||
|
||
8. Close the Cloud Shell. | ||
1. Close the Cloud Shell. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.