Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit d3fb153

Browse files
committedDec 2, 2021
edits
1 parent 160e421 commit d3fb153

File tree

3 files changed

+142
-37
lines changed

3 files changed

+142
-37
lines changed
 
Loading
Loading

‎articles/machine-learning/tutorial-create-secure-workspace-template.md

Lines changed: 142 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -8,45 +8,59 @@ ms.subservice: enterprise-readiness
88
ms.reviewer: jhirono
99
ms.author: larryfr
1010
author: blackmist
11-
ms.date: 11/29/2021
11+
ms.date: 12/02/2021
1212
ms.topic: tutorial
1313
---
1414
# How to create a secure workspace by using template
1515

16-
Templates provide a convenient way to create reproducible service deployments. The template defines what will be created, with some information provided by you when you use the template. For example, specifying a unique name for the services.
16+
Templates provide a convenient way to create reproducible service deployments. The template defines what will be created, with some information provided by you when you use the template. For example, specifying a unique name for the Azure Machine Learning workspace.
1717

18-
In this tutorial, you learn how to use a template with [Hashicorp Terraform](https://www.terraform.io/) to create the following Azure resources:
18+
In this tutorial, you learn how to use a [Microsoft Bicep](/azure/azure-resource-manager/bicep/overview) and [Hashicorp Terraform](https://www.terraform.io/) template to create the following Azure resources:
1919

20-
* Azure resource group
21-
* Azure Virtual Network
22-
* Azure Machine Learning workspace
23-
* Azure Machine Learning compute instance
24-
* Azure Machine Learning compute cluster
25-
* Azure Storage Account
26-
* Azure Key Vault
27-
* Azure Application Insights
28-
* Azure Container Registry
29-
* Azure Bastion host
30-
* Azure Machine Learning Virtual Machine (Data Science Virtual Machine)
31-
32-
> [!IMPORTANT]
33-
> The Data Science Virtual Machine (DSVM) and compute instance resources bill you for every hour that they are running. To avoid excess charges, you should stop these resources when they are not in use. For more information, see the following articles:
34-
>
35-
> * [Create/manage VMs (Linux)](/azure/virtual-machines/linux/tutorial-manage-vm).
36-
> * [Create/manage VMs (Windows)](/azure/virtual-machines/windows/tutorial-manage-vm).
37-
> * [Create/manage compute instance](how-to-create-manage-compute-instance.md).
20+
* Azure Virtual Network. The following resources are secured behind this VNet:
21+
* Azure Machine Learning workspace
22+
* Azure Machine Learning compute instance
23+
* Azure Machine Learning compute cluster
24+
* Azure Storage Account
25+
* Azure Key Vault
26+
* Azure Application Insights
27+
* Azure Container Registry
28+
* Azure Bastion host
29+
* Azure Machine Learning Virtual Machine (Data Science Virtual Machine)
30+
* The __Bicep__ template also creates an Azure Kubernetes Service cluster, and a separate resource group for it.
3831

3932
## Prerequisites
4033

4134
Before using the steps in this article, you must have an Azure subscription. If you don't have an Azure subscription, create a [free account](https://azure.microsoft.com/free/).
4235

43-
1. To install, configure, and authenticate Terraform to your Azure subscription, follow the steps in one of the following articles:
36+
You must also have either a Bash or Azure PowerShell command line.
37+
38+
> [!TIP]
39+
> When reading this article, use the tabs in each section to select whether to view information on using Bicep or Terraform templates.
40+
41+
# [Bicep](#tab/bicep)
42+
43+
1. To install the command-line tools, see [Set up Bicep development and deployment environments](/azure/azure-resource-manager/bicep/install).
44+
45+
1. The Bicep template used in this article is located at [https://github.com/Azure/azure-quickstart-templates/blob/master/quickstarts/microsoft.machinelearningservices/machine-learning-end-to-end-secure](https://github.com/Azure/azure-quickstart-templates/blob/master/quickstarts/microsoft.machinelearningservices/machine-learning-end-to-end-secure). Use the following commands to clone the GitHub repo to your development environment:
46+
47+
> [!TIP]
48+
> If you do not have the `git` command on your development environment, you can install it from [https://git-scm.com/](https://git-scm.com/).
49+
50+
```azurecli
51+
git clone https://github.com/Azure/azure-quickstart-templates
52+
cd azure-quickstart-templates/quickstarts/microsoft.machinelearningservices/machine-learning-end-to-end-secure
53+
```
54+
55+
# [Terraform](#tab/terraform)
56+
57+
1. To install, configure, and authenticate Terraform to your Azure subscription, use the steps in one of the following articles:
4458
4559
* [Azure Cloud Shell](/azure/developer/terraform/get-started-cloud-shell-bash)
4660
* [Windows with Bash](/azure/developer/terraform/get-started-windows-bash)
4761
* [Windows with Azure PowerShell](/azure/developer/terraform/get-started-windows-powershell)
4862
49-
1. The template files used in this article are located at [https://github.com/Azure/terraform/tree/master/quickstart/201-machine-learning-moderately-secure](https://github.com/Azure/terraform/tree/master/quickstart/201-machine-learning-moderately-secure). To clone the repo locally and change directory to where the template files are located, use the following commands from the command line:
63+
1. The Terraform template files used in this article are located at [https://github.com/Azure/terraform/tree/master/quickstart/201-machine-learning-moderately-secure](https://github.com/Azure/terraform/tree/master/quickstart/201-machine-learning-moderately-secure). To clone the repo locally and change directory to where the template files are located, use the following commands from the command line:
5064
5165
> [!TIP]
5266
> If you do not have the `git` command on your development environment, you can install it from [https://git-scm.com/](https://git-scm.com/).
@@ -56,26 +70,104 @@ Before using the steps in this article, you must have an Azure subscription. If
5670
cd terraform/quickstart/201-machine-learning-moderately-secure
5771
```
5872
73+
---
5974
## Understanding the template
6075
76+
# [Bicep](#tab/bicep)
77+
78+
The Bicep template is made up of the [main.bicep](https://github.com/Azure/azure-quickstart-templates/blob/master/quickstarts/microsoft.machinelearningservices/machine-learning-end-to-end-secure/main.bicep) and the `.bicep` files in the [modules](https://github.com/Azure/azure-quickstart-templates/tree/master/quickstarts/microsoft.machinelearningservices/machine-learning-end-to-end-secure/modules) subdirectory. The following table describes what each file is responsible for:
79+
80+
| File | Description |
81+
| ----- | ----- |
82+
| [main.bicep](https://github.com/Azure/azure-quickstart-templates/blob/master/quickstarts/microsoft.machinelearningservices/machine-learning-end-to-end-secure/main.bicep) | Parameters and variables. Passing parameters & variables to other modules in the `modules` subdirectory. |
83+
| [vnet.bicep](https://github.com/Azure/azure-quickstart-templates/blob/master/quickstarts/microsoft.machinelearningservices/machine-learning-end-to-end-secure/modules/vnet.bicep) | Defines the Azure Virtual Network and subnets. |
84+
| [nsg.bicep](https://github.com/Azure/azure-quickstart-templates/blob/master/quickstarts/microsoft.machinelearningservices/machine-learning-end-to-end-secure/modules/nsg.bicep) | Defines the network security group rules for the VNet. |
85+
| [bastion.bicep](https://github.com/Azure/azure-quickstart-templates/blob/master/quickstarts/microsoft.machinelearningservices/machine-learning-end-to-end-secure/modules/bastion.bicep) | Defines the Azure Bastion host and subnet. Azure Bastion allows you to easily access a VM inside the VNet using your web browser. |
86+
| [dsvmjumpbox.bicep](https://github.com/Azure/azure-quickstart-templates/blob/master/quickstarts/microsoft.machinelearningservices/machine-learning-end-to-end-secure/modules/dsvmjumpbox.bicep) | Defines the Data Science Virtual Machine (DSVM). Azure Bastion is used to access this VM through your web browser. |
87+
| [storage.bicep](https://github.com/Azure/azure-quickstart-templates/blob/master/quickstarts/microsoft.machinelearningservices/machine-learning-end-to-end-secure/modules/storage.bicep) | Defines the Azure Storage account used by the workspace for default storage. |
88+
| [keyvault.bicep](https://github.com/Azure/azure-quickstart-templates/blob/master/quickstarts/microsoft.machinelearningservices/machine-learning-end-to-end-secure/modules/keyvault.bicep) | Defines the Azure Key Vault used by the workspace. |
89+
| [containerregistry.bicep](https://github.com/Azure/azure-quickstart-templates/blob/master/quickstarts/microsoft.machinelearningservices/machine-learning-end-to-end-secure/modules/containerregistry.bicep) | Defines the Azure Container Registry used by the workspace. |
90+
| [applicationinsights.bicep](https://github.com/Azure/azure-quickstart-templates/blob/master/quickstarts/microsoft.machinelearningservices/machine-learning-end-to-end-secure/modules/applicationinsights.bicep) | Defines the Azure Application Insights instance used by the workspace. |
91+
| [machinelearningnetworking.bicep](https://github.com/Azure/azure-quickstart-templates/blob/master/quickstarts/microsoft.machinelearningservices/machine-learning-end-to-end-secure/modules/machinelearningnetworking.bicep) | Defines te private endpoints and DNS zones for the Azure Machine Learning workspace. |
92+
| [Machinelearning.bicep](https://github.com/Azure/azure-quickstart-templates/blob/master/quickstarts/microsoft.machinelearningservices/machine-learning-end-to-end-secure/modules/machinelearning.bicep) | Defines the Azure Machine Learning workspace. |
93+
| [machinelearningcompute.bicep](https://github.com/Azure/azure-quickstart-templates/blob/master/quickstarts/microsoft.machinelearningservices/machine-learning-end-to-end-secure/modules/machinelearningcompute.bicep) | Defines an Azure Machine Learning compute cluster and compute instance. |
94+
| [privateaks.bicep] | Defines an Azure Kubernetes Services cluster instance. |
95+
96+
# [Terraform](#tab/terraform)
97+
6198
The template consists of multiple files. The following table describes what each file is responsible for:
6299
63100
| File | Description |
64101
| ----- | ----- |
65102
| [variables.tf](https://github.com/Azure/terraform/blob/master/quickstart/201-machine-learning-moderately-secure/variables.tf) | Variables and default values used by the template.
66103
| [main.tf](https://github.com/Azure/terraform/blob/master/quickstart/201-machine-learning-moderately-secure/main.tf) | Specifies the Azure Resource Manager provider and defines the resource group. |
67-
| [network.tf](https://github.com/Azure/terraform/blob/master/quickstart/201-machine-learning-moderately-secure/network.tf) | Defines the Azure Virtual Network (VNet), subnets, network security groups (NSG), and private DNS zones. |
104+
| [network.tf](https://github.com/Azure/terraform/blob/master/quickstart/201-machine-learning-moderately-secure/network.tf) | Defines the Azure Virtual Network, subnets, and network security groups. |
68105
| [bastion.tf](https://github.com/Azure/terraform/blob/master/quickstart/201-machine-learning-moderately-secure/bastion.tf) | Defines the Azure Bastion host and associated NSG. Azure Bastion allows you to easily access a VM inside a VNet using your web browser. |
69-
| [dsvm.tf](https://github.com/Azure/terraform/blob/master/quickstart/201-machine-learning-moderately-secure/dsvm.tf) | Defines the Azure Virtual Machine (a Data Science Virtual Machine, or DSVM). Azure Bastion is used to access this VM through your web browser. |
70-
| [workspace.tf](https://github.com/Azure/terraform/blob/master/quickstart/201-machine-learning-moderately-secure/workspace.tf) | Defines the Azure Machine Learning workspace. Including dependency resources for Azure Storage, Key Vault, Application Insights, and Container Registry. It also defines an Azure Machine Learning compute cluster. The compute cluster is required for building Docker images when Container Registry is secured in the VNet. |
106+
| [dsvm.tf](https://github.com/Azure/terraform/blob/master/quickstart/201-machine-learning-moderately-secure/dsvm.tf) | Defines the Data Science Virtual Machine (DSVM). Azure Bastion is used to access this VM through your web browser. |
107+
| [workspace.tf](https://github.com/Azure/terraform/blob/master/quickstart/201-machine-learning-moderately-secure/workspace.tf) | Defines the Azure Machine Learning workspace. Including dependency resources for Azure Storage, Key Vault, Application Insights, and Container Registry. |
71108
| [compute.tf](https://github.com/Azure/terraform/blob/master/quickstart/201-machine-learning-moderately-secure/compute.tf) | Defines an Azure Machine Learning compute instance and cluster. |
72109
110+
> [!TIP]
111+
> The [Terraform Azure provider](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs) supports additional arguments that are not used in this tutorial. For example, the [environment](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs#environment) argument allows you to target cloud regions such as Azure Government and Azure China 21ViaNet.
112+
113+
---
114+
73115
> [!IMPORTANT]
74-
> The DSVM is used as an easy way to connect to the secured workspace for this tutorial. In a production environment, we recommend using an [Azure VPN gateway](/azure/vpn-gateway/vpn-gateway-about-vpngateways) or [Azure ExpressRoute](/azure/expressroute/expressroute-introduction) to access the resources inside the VNet.
116+
> The DSVM and Azure Bastion is used as an easy way to connect to the secured workspace for this tutorial. In a production environment, we recommend using an [Azure VPN gateway](/azure/vpn-gateway/vpn-gateway-about-vpngateways) or [Azure ExpressRoute](/azure/expressroute/expressroute-introduction) to access the resources inside the VNet directly from your on-premises network.
75117
76118
## Configure the template
77119
78-
To run the template, use the following commands from the `201-machine-learning-moderately-secure` directory:
120+
# [Bicep](#tab/bicep)
121+
122+
To run the Terraform template, use the following commands from the `machine-learning-end-to-end-secure` where the `main.bicep` file is:
123+
124+
1. To create a new Azure Resource Group, use the following command. Replace `exampleRG` with your resource group name, and `eastus` with the Azure region you want to use:
125+
126+
# [Azure CLI](#tab/cli)
127+
128+
```azurecli
129+
az group create --name exampleRG --location eastus
130+
```
131+
# [Azure PowerShell](#tab/ps1)
132+
133+
```azurepowershell
134+
New-AzResourceGroup -Name exampleRG -Location eastus
135+
```
136+
137+
---
138+
139+
1. To run the template, use the following command:
140+
141+
# [Azure CLI](#tab/cli)
142+
143+
```azurecli
144+
az deployment group create \
145+
--resource-group exampleRG \
146+
--template-file main.bicep \
147+
--parameters \
148+
prefix=myprefix \
149+
dsvmJumpboxUsername=azureadmin \
150+
dsvmJumpboxPassword=securepassword
151+
```
152+
# [Azure PowerShell](#tab/ps1)
153+
154+
```azurepowershell
155+
$dsvmPassword = ConvertTo-SecureString "mysecurepassword" -AsPlainText -Force
156+
New-AzResourceGroupDeployment -ResourceGroupName exampleRG `
157+
-TemplateFile ./main.bicep `
158+
-prefix "myprefix" `
159+
-dsvmJumpboxUsername "azureadmin" `
160+
-dsvmJumpboxPassword $dsvmPassword
161+
```
162+
163+
> [!WARNING]
164+
> You should avoid using plain text strings in script or from the command line. The plain text can show up in event logs and command history. For more information, see [ConvertTo-SecureString](/powershell/module/microsoft.powershell.security/convertto-securestring).
165+
166+
---
167+
168+
# [Terraform](#tab/terraform)
169+
170+
To run the Terraform template, use the following commands from the `201-machine-learning-moderately-secure` directory where the template files are:
79171
80172
1. To initialize the directory for working with Terraform, use the following command:
81173
@@ -97,31 +189,44 @@ To run the template, use the following commands from the `201-machine-learning-m
97189
98190
After this command completes, the configuration is displayed in the terminal. To display it again, use the `terraform show azureml.tfplan` command.
99191
100-
## Run the template
192+
1. To run the template and apply the saved configuration to your Azure subscription, use the following command:
101193
102-
To run the template and apply the saved configuration to your Azure subscription, use the following command:
194+
```azurecli
195+
terraform apply azureml.tfplan
196+
```
103197
104-
```azurecli
105-
terraform apply azureml.tfplan
106-
```
198+
The progress is displayed as the template is processed.
107199
108-
The progress is displayed as the template is processed.
200+
---
109201
110202
## Connect to the workspace
111203
112204
After the template completes, use the following steps to connect to the DSVM:
113205
114-
1. From the [Azure portal](https://portal.azure.com), select the DSVM that was created by the template.
115-
1. From the __Overview__ page, select __Connect__, and then select __Bastion__ from the dropdown.
206+
1. From the [Azure portal](https://portal.azure.com), select the Azure Resource Group you used with the template. Then, select the Data Science Virtual Machine that was created by the template. If you have trouble finding it, use the filters section to filter the __Type__ to __virtual machine__.
207+
208+
:::image type="content" source="./media/tutorial-create-secure-workspace-template/select-vm.png" alt-text="Screenshot of filtering and selecting the vm.":::
209+
210+
1. From the __Overview__ section of the Virtual Machine, select __Connect__, and then select __Bastion__ from the dropdown.
211+
212+
:::image type="content" source="./media/tutorial-create-secure-workspace-template/connect-bastion.png" alt-text="Screenshot of selecting to connect using Bastion.":::
213+
116214
1. When prompted, provide the __username__ and __password__ you specified when configuring the template and then select __Connect__.
117215
118216
> [!IMPORTANT]
119217
> The first time you connect to the DSVM desktop, a PowerShell window opens and begins running a script. Allow this to complete before continuing with the next step.
120218
121-
1. From the DSVM desktop, start __Microsoft Edge__ and enter `https://ml.azure.com` as the address. Sign in to your Azure subscription, and then select the workspace created by the template.
219+
1. From the DSVM desktop, start __Microsoft Edge__ and enter `https://ml.azure.com` as the address. Sign in to your Azure subscription, and then select the workspace created by the template. The studio for your workspace is displayed.
122220
123221
## Next steps
124222
223+
> [!IMPORTANT]
224+
> The Data Science Virtual Machine (DSVM) and any compute instance resources bill you for every hour that they are running. To avoid excess charges, you should stop these resources when they are not in use. For more information, see the following articles:
225+
>
226+
> * [Create/manage VMs (Linux)](/azure/virtual-machines/linux/tutorial-manage-vm).
227+
> * [Create/manage VMs (Windows)](/azure/virtual-machines/windows/tutorial-manage-vm).
228+
> * [Create/manage compute instance](how-to-create-manage-compute-instance.md).
229+
125230
To continue learning how to use the secured workspace from the DSVM, see [Tutorial: Get started with a Python script in Azure Machine Learning](tutorial-1st-experiment-hello-world.md).
126231
127232
To learn more about common secure workspace configurations and input/output requirements, see [Azure Machine Learning secure workspace traffic flow](concept-secure-network-traffic-flow.md).

0 commit comments

Comments
 (0)
Please sign in to comment.