|
| 1 | +--- |
| 2 | +title: 'Workspace soft-delete overview' |
| 3 | +titleSuffix: Azure Machine Learning |
| 4 | +description: Recover workspace data after accidental deletion with soft delete |
| 5 | +services: machine-learning |
| 6 | +ms.service: machine-learning |
| 7 | +ms.subservice: core |
| 8 | +ms.custom: |
| 9 | +ms.topic: conceptual |
| 10 | +ms.author: deeikele |
| 11 | +author: deeikele |
| 12 | +ms.date: 08/25/2022 |
| 13 | +#Customer intent: As an IT pro, understand how to enable data protection capabilities, to protect against accidental deletion. |
| 14 | +--- |
| 15 | + |
| 16 | +# Recover workspace data after accidental deletion with soft delete (Preview) |
| 17 | + |
| 18 | +Workspace soft delete provides a data protection capability to help attempt recovery of workspace data after accidental deletion of a workspace. Soft delete introduces a two-step approach in deleting a workspace. When a workspace is deleted, it is first soft deleted. While in soft-deleted state, you can choose to recover or permanently delete a workspace and its data during a data retention period. |
| 19 | + |
| 20 | +## Soft-delete behavior |
| 21 | + |
| 22 | +When a workspace is soft-deleted, data and metadata stored service-side get soft-deleted, but some configurations get hard-deleted. Below table provides an overview of which configurations and objects get soft-deleted, and which are hard-deleted. |
| 23 | + |
| 24 | +> [!IMPORTANT] |
| 25 | +> Workspaces encrypted with customer-managed keys (CMK) are not enabled for soft delete and are always hard deleted. |
| 26 | +
|
| 27 | +Data / configuration | Soft-deleted | Hard-deleted |
| 28 | +---|---|--- |
| 29 | +Run History | X | |
| 30 | +Models | X | |
| 31 | +Data | X | |
| 32 | +Environments | x | |
| 33 | +Components | X | |
| 34 | +Notebooks | X | |
| 35 | +Pipelines | X | |
| 36 | +Designer pipelines | X | |
| 37 | +AutoML jobs | X | |
| 38 | +Data labeling projects | X | |
| 39 | +Datastores | X | |
| 40 | +Queued or running jobs | | X |
| 41 | +Role assignments | | X* |
| 42 | +Internal cache | | X |
| 43 | +Compute instance | | X |
| 44 | +Compute clusters | | X |
| 45 | +Inference endpoints | | X |
| 46 | +Linked Databricks workspaces | | X* |
| 47 | + |
| 48 | +\* Microsoft attempts recreation or re-attachment when a workspace is recovered |
| 49 | + |
| 50 | +Soft delete is enabled on any workspaces for subscription that are enrolled for the soft-delete preview capability. During preview, workspaces with customer-managed keys are not supported for soft-delete. Soft deleted workspaces do not incur costs, since cost-incurring resources are hard deleted at time of workspace deletion. |
| 51 | + |
| 52 | +Recently deleted workspaces can be queried through CLI/SDK/REST options and the Azure Portal, and can be recovered or permanently deleted during the data retention period. After expiry of the retention period, a soft deleted workspace automatically gets hard deleted. A data retention period of 14 days is the default, and can be set to a value between 1-14 as a property on the workspace through CLI/SDK/REST and template options. |
| 53 | + |
| 54 | +## Enroll soft-delete on an Azure subscription |
| 55 | + |
| 56 | +* Soft delete is the default behavior going forward on all workspaces, except for workspaces encrypted with a customer-managed key (CMK). |
| 57 | +* A data retention period of 14 days is the default, and can be set to a value between 1-14 as a property on the workspace through CLI/SDK/REST and template options. We are dependent on Azure Storage who has a retention period of deleted storage accounts of 14 days. This limitation may be solved with proposed HOBO workspace-storage. |
| 58 | +* Recently deleted workspaces can be queried through CLI/SDK/REST options and the Azure Portal, and can be recovered or permanently deleted during the data retention period. After expiry of the retention period, a soft deleted workspace automatically gets hard deleted. |
| 59 | + |
| 60 | +## Manage soft-deleted workspaces |
| 61 | + |
| 62 | +Recently deleted workspaces can be managed from the Azure Portal, CLI and SDK. |
| 63 | + |
| 64 | +### Azure Portal |
| 65 | + |
| 66 | +### CLI and SDK |
| 67 | + |
| 68 | +#### Configure soft delete retention period |
| 69 | + |
| 70 | +A data retention period for a soft deleted workspace may be specified on storage. |
| 71 | + |
| 72 | +CLI: |
| 73 | +```cli |
| 74 | +> az ml workspace create --subscription {SUBSCRIPTION ID} -g {RESOURCE GROUP} -n {WORKSPACE NAME} -f soft-delete.yaml |
| 75 | +``` |
| 76 | + |
| 77 | +```yaml |
| 78 | +#source ../configs/workspace/soft-delete.yaml |
| 79 | +name: soft-delete-ws |
| 80 | +location: EastUS |
| 81 | +display_name: soft-delete-workspace |
| 82 | +description: A workspace with configured retention period for soft delete |
| 83 | + |
| 84 | +data_retention: |
| 85 | + soft_delete_retention_days: 14 |
| 86 | + |
| 87 | +tags: |
| 88 | + purpose: testing |
| 89 | + team: ws-management |
| 90 | +``` |
| 91 | +
|
| 92 | +SDK: |
| 93 | +```python |
| 94 | +workspace = Workspace.create( |
| 95 | + subscription_id="{SUBSCRIPTION ID}", |
| 96 | + resource_group="{RESOURCE GROUP}", |
| 97 | + name="soft-delete-ws", |
| 98 | + soft_delete_retention_days=14 |
| 99 | +) |
| 100 | +``` |
| 101 | + |
| 102 | +> The default retention period is 14 days, but can be set to avalue between 1 and 14 days to meet data residency or other compliance requirements. CLI and SDK operations should fail if a value is provided outside of this range. |
| 103 | +
|
| 104 | +#### Soft delete a workspace |
| 105 | + |
| 106 | +Soft delete is the default behavior when deleting a non-CMK workspace. |
| 107 | + |
| 108 | +> Deletion of dependent resources is only possible in combination with permanently deleting a workspace, and fails in case a workspace is not permanently deleted to allow for best changes of recovering workspace data. |
| 109 | +
|
| 110 | +CLI: |
| 111 | +```cli |
| 112 | +az ml workspace delete --subscription {SUBSCRIPTION ID} -g {RESOURCE GROUP} -n {WORKSPACE NAME} |
| 113 | +``` |
| 114 | + |
| 115 | +SDK: |
| 116 | +```python |
| 117 | +workspace.delete( |
| 118 | + subscription_id="{SUBSCRIPTION ID}", |
| 119 | + resource_group="{RESOURCE GROUP}", |
| 120 | + delete_dependent_resources=False, |
| 121 | + permanently_delete=False, |
| 122 | + no_wait=False |
| 123 | +) |
| 124 | +``` |
| 125 | + |
| 126 | +#### Permanently delete a workspace |
| 127 | + |
| 128 | +Optionally, you may choose to permanently delete a non-CMK workspace without going to soft delete state first by setting the `permanently_delete` flag. By default, this parameter is set to `false`. Permanently deleting a workspace allows recreation to accomodate for dev/test MLOps scenarios, or to immediately delete highly sensitive data if required. |
| 129 | + |
| 130 | +CLI: |
| 131 | +```cli |
| 132 | +az ml workspace delete --subscription {SUBSCRIPTION ID} -g {RESOURCE GROUP} -n {WORKSPACE NAME} --permanently_delete |
| 133 | +``` |
| 134 | + |
| 135 | +SDK: |
| 136 | +```python |
| 137 | +workspace.delete( |
| 138 | + subscription_id="{SUBSCRIPTION ID}", |
| 139 | + resource_group="{RESOURCE GROUP}", |
| 140 | + delete_dependent_resources=False, |
| 141 | + permanently_delete=True, |
| 142 | + no_wait=False |
| 143 | +) |
| 144 | +``` |
| 145 | + |
| 146 | +#### List workspaces |
| 147 | + |
| 148 | +Soft deleted workspaces should not show in az ml workspace list commands. |
| 149 | + |
| 150 | +#### List soft-deleted workspaces |
| 151 | + |
| 152 | +Soft-deleted workspaces can be listed by subscription, and by resource group. List by subscription allows customers to query soft deleted workspace for which the resource group was deleted as well. |
| 153 | + |
| 154 | +> Design should be extensible to future interfaces provided by Azure Resource Manager. ARM will expose Microsoft.Resources/deletedResources API, which can be called to list soft deleted workspaces on subscription and resource group level. |
| 155 | +
|
| 156 | +Query results must provide subscription, original resource group and original name of the soft deleted resource. |
| 157 | + |
| 158 | +CLI: |
| 159 | +```cli |
| 160 | +az ml workspace list-deleted --subscription {SUBSCRIPTION ID} --resource_group {RESOURCE GROUP} |
| 161 | +``` |
| 162 | + |
| 163 | +SDK: |
| 164 | +```python |
| 165 | +Workspace.list_deleted( |
| 166 | + subscription_id="{SUBSCRIPTION ID}", |
| 167 | + resource_group="{RESOURCE GROUP}", # Optional |
| 168 | +) |
| 169 | +``` |
| 170 | + |
| 171 | +#### Get a soft-deleted workspace |
| 172 | + |
| 173 | +Regular `az ml workspace show` should return 404 for soft-deleted workspaces. Instead, soft-deleted workspaces can be shown via a show-deleted call, by providing subscription, original resource group and *original* name of the soft deleted resource. *Original*, since the resource group may have been deleted at this point. This aligns with ARMs future interface, where deleted resources can be queried by original resource URIs. |
| 174 | + |
| 175 | +CLI: |
| 176 | +```cli |
| 177 | +az ml workspace show-deleted --subscription {SUBSCRIPTION ID} --resource_group --name {WORKSPACE NAME} |
| 178 | +``` |
| 179 | + |
| 180 | +SDK |
| 181 | +```python |
| 182 | +workspace.get_deleted( |
| 183 | + name="soft-delete-ws", |
| 184 | + subscription_id="{SUBSCRIPTION ID}", |
| 185 | + resource_group="{RESOURCE GROUP}" |
| 186 | +) |
| 187 | + |
| 188 | +``` |
| 189 | + |
| 190 | +#### Recover soft-deleted workspace |
| 191 | + |
| 192 | +To recover a deleted workspace, provide subscription id, original resource group and original name of the soft deleted workspace. |
| 193 | + |
| 194 | +CLI: |
| 195 | +```cli |
| 196 | +az ml workspace recover --subscription {SUBSCRIPTION ID} --resource_group {RESOURCE GROUP} --name {WORKSPACE NAME} |
| 197 | +``` |
| 198 | + |
| 199 | +SDK: |
| 200 | +```python |
| 201 | +Workspace.recover( |
| 202 | + subscription_id="{SUBSCRIPTION ID}", |
| 203 | + resource_group="{RESOURCE GROUP}", |
| 204 | + name="soft-delete-ws", |
| 205 | +) |
| 206 | +``` |
| 207 | + |
| 208 | +> Since workspace is already deleted, it cannot be instantiated and recovery may be implemented as a static method. |
| 209 | +
|
| 210 | +## Next steps |
| 211 | + |
| 212 | ++ [Create and manage a workspace](how-to-manage-workspace.md) |
0 commit comments