Skip to content

Commit 6027754

Browse files
authored
Merge pull request #77091 from Blackmist/storage-key
Storage key
2 parents 9606608 + 6c84048 commit 6027754

File tree

3 files changed

+117
-2
lines changed

3 files changed

+117
-2
lines changed

articles/machine-learning/service/concept-enterprise-security.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ The following table lists some of the major Azure Machine Learning service opera
7070
| View models/images ||||
7171
| Call web service ||||
7272

73-
If the built-in roles are insufficient for your needs, you can also create custom roles. Note that the only custom roles we support are for operations on the workspace and Machine Learning Compute. The custom roles may have read, write, or delete permissions on the workspace and the compute resource in that workspace. You can make the role available at a specific workspace level, a specific resource group level, or a specific subscription level. For more information, see [Manage users and roles in an Azure Machine Learning workspace](how-to-assign-roles.md)
73+
If the built-in roles are insufficient for your needs, you can also create custom roles. The only custom roles we support are for operations on the workspace and Machine Learning Compute. The custom roles may have read, write, or delete permissions on the workspace and the compute resource in that workspace. You can make the role available at a specific workspace level, a specific resource group level, or a specific subscription level. For more information, see [Manage users and roles in an Azure Machine Learning workspace](how-to-assign-roles.md)
7474

7575
### Securing compute and data
7676
Owners and contributors can use all compute targets and data stores that are attached to the workspace.
@@ -89,7 +89,7 @@ For more information on managed identities, see [Managed identities for Azure re
8989

9090
It is recommended that administrators do not revoke the access of the managed identity to the resources mentioned above. Access can be restored with the Resync Keys operation.
9191

92-
Azure Machine Learning service creates an additional application (name starts with aml-) with the contributor level access in your subscription for every workspace region. For ex. if you have a workspace in East US and another workspace in North Europe in the same subscription you will see 2 such applications. This is needed so that Azure Machine Learning service can help manage compute resources.
92+
Azure Machine Learning service creates an additional application (name starts with `aml-`) with the contributor level access in your subscription for every workspace region. For ex. if you have a workspace in East US and another workspace in North Europe in the same subscription you will see two such applications. This is needed so that Azure Machine Learning service can help manage compute resources.
9393

9494

9595
## Network security
@@ -108,6 +108,8 @@ For more information on how to bring your own keys for the data stored in Azure
108108

109109
Training data is typically also stored in Azure Blob storage so that it is accessible to training compute. This storage is not managed by Azure Machine Learning but mounted to compute as a remote file system.
110110

111+
For information on regenerating the access keys for the Azure storage accounts used with your workspace, see the [Regenerate storage access keys](how-to-change-storage-access-key.md) article.
112+
111113
#### Cosmos DB
112114
Azure Machine Learning service stores metrics and metadata to the Cosmos DB that lives in a Microsoft subscription managed by Azure Machine Learning service. All the data stored in Cosmos DB is encrypted at rest using Microsoft Managed Keys.
113115

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
---
2+
title: Change storage account access keys
3+
titleSuffix: Azure Machine Learning service
4+
description: Learn how to change the access keys for the Azure Storage account used by your workspace. Azure Machine Learning service uses an Azure Storage account to store data and models. When you regenerate the access key for the storage account, you must update the Azure Machine Learning service to use the new keys.
5+
services: machine-learning
6+
ms.service: machine-learning
7+
ms.subservice: core
8+
ms.topic: conceptual
9+
ms.author: aashishb
10+
author: aashishb
11+
ms.reviewer: larryfr
12+
ms.date: 05/17/2019
13+
14+
15+
---
16+
17+
# Regenerate storage account access keys
18+
19+
Learn how to change the access keys for Azure Storage accounts used by the Azure Machine Learning service. Azure Machine Learning can use storage accounts to store data or trained models.
20+
21+
For security purposes, you may need to change the access keys for an Azure Storage account. When you regenerate the access key, Azure Machine Learning must be updated to use the new key. Azure Machine Learning may be using the storage account for both model storage and as a datastore.
22+
23+
## Prerequisites
24+
25+
* An Azure Machine Learning service workspace. For more information, see the [Create a workspace](setup-create-workspace.md) article.
26+
27+
* The [Azure Machine Learning SDK](https://docs.microsoft.com/python/api/overview/azure/ml/install?view=azure-ml-py).
28+
29+
* The [Azure Machine Learning CLI extension](reference-azure-machine-learning-cli.md).
30+
31+
<a id="whattoupdate"></a>
32+
33+
## What needs to be updated
34+
35+
Storage accounts can be used by the Azure Machine Learning service workspace (storing logs, models, snapshots, etc.) and as a datastore. The process to update the workspace is a single Azure CLI command, and can be ran after updating the storage key. The process of updating datastores is more involved, and requires discovering what datastores are currently using the storage account and then re-registering them.
36+
37+
> [!IMPORTANT]
38+
> Update the workspace using the Azure CLI, and the datastores using Python, at the same time. Updating only one or the other is not sufficient, and may cause errors until both are updated.
39+
40+
To discover the storage accounts that are used by your datastores, use the following code:
41+
42+
```python
43+
import azureml.core
44+
from azureml.core import Workspace, Datastore
45+
46+
ws = Workspace.from_config()
47+
48+
default_ds = ws.get_default_datastore()
49+
print("Default datstore: " + default_ds.name + ", storage account name: " + default_ds.account_name + ", container name: " + ds.container_name)
50+
51+
datastores = ws.datastores
52+
for name, ds in datastores.items():
53+
if ds.datastore_type == "AzureBlob" or ds.datastore_type == "AzureFile":
54+
print("datastore name: " + name + ", storage account name: " + ds.account_name + ", container name: " + ds.container_name)
55+
```
56+
57+
This code looks for any registered datastores that use Azure Storage and lists the following information:
58+
59+
* Datastore name: The name of the datastore that the storage account is registered under.
60+
* Storage account name: The name of the Azure Storage account.
61+
* Container: The container in the storage account that is used by this registration.
62+
63+
If an entry exists for the storage account that you plan on regenerating access keys for, save the datastore name, storage account name, and container name.
64+
65+
## Update the access key
66+
67+
To update Azure Machine Learning service to use the new key, use the following steps:
68+
69+
> [!IMPORTANT]
70+
> Perform all steps, updating both the workspace using the CLI, and datastores using Python. Updating only one or the other may cause errors until both are updated.
71+
72+
1. Regenerate the key. For information on regenerating an access key, see the [Manage a storage account](/azure/storage/common/storage-account-manage.md#access-keys) article. Save the new key.
73+
74+
1. To update the workspace to use the new key, use the following steps:
75+
76+
1. To sign in to the Azure subscription that contains your workspace by using the following Azure CLI command:
77+
78+
```azurecli-interactive
79+
az login
80+
```
81+
82+
1. To install the Azure Machine Learning extension, use the following command:
83+
84+
```azurecli-interactive
85+
az extension add -n azure-cli-ml
86+
```
87+
88+
1. To update the workspace to use the new key, use the following command. Replace `myworkspace` with your Azure Machine Learning workspace name, and replace `myresourcegroup` with the name of the Azure resource group that contains the workspace.
89+
90+
```azurecli-interactive
91+
az ml workspace sync-keys -w myworkspace -g myresourcegroup
92+
```
93+
94+
This command automatically syncs the new keys for the Azure storage account used by the workspace.
95+
96+
1. To re-register datastore(s) that use the storage account, use the values from the [What needs to be updated](#whattoupdate) section and the key from step 1 with the following code:
97+
98+
```python
99+
ds = Datastore.register_azure_blob_container(workspace=ws,
100+
datastore_name='your datastore name',
101+
container_name='your container name',
102+
account_name='your storage account name',
103+
account_key='new storage account key',
104+
overwrite=True)
105+
```
106+
107+
Since `overwrite=True` is specified, this code overwrites the existing registration and updates it to use the new key.
108+
109+
## Next steps
110+
111+
For more information on registering datastores, see the [`Datastore`](https://docs.microsoft.com/python/api/azureml-core/azureml.core.datastore(class)?view=azure-ml-py) class reference.

articles/machine-learning/service/toc.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,8 @@
118118
href: how-to-enable-virtual-network.md
119119
- name: Secure web services with SSL
120120
href: how-to-secure-web-service.md
121+
- name: Regenerate storage access keys
122+
href: how-to-change-storage-access-key.md
121123
- name: How-to guides
122124
items:
123125
- name: Manage workspaces

0 commit comments

Comments
 (0)