Skip to content

Commit 75ed8ab

Browse files
committed
Update how-to-create-manage-compute-instance.md
1 parent 154b152 commit 75ed8ab

File tree

1 file changed

+27
-1
lines changed

1 file changed

+27
-1
lines changed

articles/machine-learning/how-to-create-manage-compute-instance.md

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,32 @@ Following is a sample policy to default a shutdown schedule at 10 PM PST.
344344
}
345345
```
346346

347+
## Assign managed identity (preview)
348+
349+
You can assign a system- or user-assigned [managed identity](https://docs.microsoft.com/azure/active-directory/managed-identities-azure-resources/overview) to a compute instance, to autheticate against other Azure resources such as storage. Using managed identities for authentication helps improve workspace security and management. For example you can allow users to access training data only when logged in to compute instance, or use a common user-assigned managed identity to permit access to a specific storage account.
350+
351+
1. Fill out the form to [create a new compute instance](?tabs=azure-studio#create).
352+
1. Select **Next: Advanced Settings**.
353+
1. Enable **Assign a managed identity**.
354+
1. Select **System-assigned** or **User-assigned** under **Identity type**.
355+
1. If you selected **User-assigned**, select subscription and name of the identity.
356+
357+
When working on the compute instance, the managed identity is used automatically to authenticate against data stores with [identity-based data access enabled](how-to-identity-based-data-access.md).
358+
359+
You can also use the managed identity manually to authenticate against other Azure resources. For example, to use it to get ARM access token, use following.
360+
361+
```python
362+
import requests
363+
364+
def get_access_token_msi(resource):
365+
client_id = os.environ.get("DEFAULT_IDENTITY_CLIENT_ID", None)
366+
resp = requests.get(f"{os.environ['MSI_ENDPOINT']}?resource={resource}&clientid={client_id}&api-version=2017-09-01", headers={'Secret': os.environ["MSI_SECRET"]})
367+
resp.raise_for_status()
368+
return resp.json()["access_token"]
369+
370+
arm_access_token = get_access_token_msi("https://management.azure.com")
371+
```
372+
347373
## Add custom applications such as RStudio (preview)
348374

349375
You can set up other applications, such as RStudio, when creating a compute instance. Follow these steps in studio to set up a custom application on your compute instance
@@ -353,7 +379,7 @@ You can set up other applications, such as RStudio, when creating a compute inst
353379
1. Select **Add application** under the **Custom application setup (RStudio Workbench, etc.)** section
354380

355381
:::image type="content" source="media/how-to-create-manage-compute-instance/custom-service-setup.png" alt-text="Screenshot showing Custom Service Setup.":::
356-
382+
357383
### Setup RStudio Workbench
358384

359385
RStudio is one of the most popular IDEs among R developers for ML and data science projects. You can easily set up RStudio Workbench to run on your compute instance, using your own RStudio license, and access the rich feature set that RStudio Workbench offers.

0 commit comments

Comments
 (0)