|
1 | 1 | ---
|
2 |
| -title: Manage workspaces using Terraform |
| 2 | +title: Create workspaces by using Terraform |
3 | 3 | titleSuffix: Azure Machine Learning
|
4 |
| -description: Learn how to manage Azure Machine Learning workspaces using Terraform. |
| 4 | +description: Learn how to create Azure Machine Learning workspaces with public or private connectivity by using Terraform. |
5 | 5 | services: machine-learning
|
6 | 6 | ms.service: machine-learning
|
7 | 7 | ms.subservice: enterprise-readiness
|
8 | 8 | ms.custom: devx-track-terraform
|
9 | 9 | ms.author: deeikele
|
10 | 10 | author: denniseik
|
11 | 11 | ms.reviewer: larryfr
|
12 |
| -ms.date: 06/05/2023 |
| 12 | +ms.date: 06/25/2024 |
13 | 13 | ms.topic: how-to
|
14 | 14 | ms.tool: terraform
|
15 | 15 | ---
|
16 | 16 |
|
17 |
| -# Manage Azure Machine Learning workspaces using Terraform |
| 17 | +# Manage Azure Machine Learning workspaces by using Terraform |
18 | 18 |
|
19 |
| -In this article, you learn how to create and manage an Azure Machine Learning workspace using Terraform configuration files. [Terraform](/azure/developer/terraform/)'s template-based configuration files enable you to define, create, and configure Azure resources in a repeatable and predictable manner. Terraform tracks resource state and is able to clean up and destroy resources. |
| 19 | +In this article, you learn how to create an Azure Machine Learning workspace by using Terraform configuration files. [Terraform](/azure/developer/terraform/) template-based configuration files enable you to define, create, and configure Azure resources in a repeatable and predictable manner. Terraform tracks resource state and can clean up and destroy resources. |
20 | 20 |
|
21 |
| -A Terraform configuration is a document that defines the resources that are needed for a deployment. It may also specify deployment variables. Variables are used to provide input values when using the configuration. |
| 21 | +A Terraform configuration file is a document that defines the resources needed for a deployment. The Terraform configuration can also specify deployment variables to use to provide input values when you apply the configuration. |
22 | 22 |
|
23 | 23 | ## Prerequisites
|
24 | 24 |
|
25 |
| -* An **Azure subscription**. If you don't have one, try the [free or paid version of Azure Machine Learning](https://azure.microsoft.com/free/). |
26 |
| -* An installed version of the [Azure CLI](/cli/azure/). |
27 |
| -* Configure Terraform: follow the directions in this article and the [Terraform and configure access to Azure](/azure/developer/terraform/get-started-cloud-shell) article. |
| 25 | +- An Azure subscription with a free or paid version of Azure Machine Learning. If you don't have an Azure subscription, [create a free account before you begin](https://azure.microsoft.com/free/). |
| 26 | +- Terraform installed and configured according to the instructions in [Quickstart: Install and configure Terraform](/azure/developer/terraform/quickstart-configure). |
| 27 | +<!--- [Azure CLI](/cli/azure/install-azure-cli) installed.--> |
28 | 28 |
|
29 | 29 | ## Limitations
|
30 | 30 |
|
31 | 31 | [!INCLUDE [register-namespace](includes/machine-learning-register-namespace.md)]
|
32 | 32 |
|
33 |
| -[!INCLUDE [application-insight](includes/machine-learning-application-insight.md)] |
| 33 | +- The following limitation applies to the Application Insights instance created during workspace creation: |
34 | 34 |
|
35 |
| -## Declare the Azure provider |
| 35 | + [!INCLUDE [application-insight](includes/machine-learning-application-insight.md)] |
36 | 36 |
|
37 |
| -Create the Terraform configuration file that declares the Azure provider: |
| 37 | +## Create the workspace |
38 | 38 |
|
39 |
| -1. Create a new file named `main.tf`. If working with Azure Cloud Shell, use bash: |
| 39 | +Create a file named *main.tf* that has the following code. |
40 | 40 |
|
41 |
| - ```bash |
42 |
| - code main.tf |
43 |
| - ``` |
| 41 | +:::code language="terraform" source="~/terraform/quickstart/101-machine-learning/main.tf"::: |
44 | 42 |
|
45 |
| -1. Paste the following code into the editor: |
| 43 | +Declare the Azure provider in a file named *providers.tf* that has the following code. |
46 | 44 |
|
47 |
| - **main.tf**: |
48 |
| - :::code language="terraform" source="~/terraform/quickstart/101-machine-learning/main.tf"::: |
| 45 | +:::code language="terraform" source="~/terraform/quickstart/101-machine-learning/providers.tf"::: |
49 | 46 |
|
50 |
| -1. Save the file (**<Ctrl>S**) and exit the editor (**<Ctrl>Q**). |
| 47 | +### Configure the workspace |
51 | 48 |
|
52 |
| -## Deploy a workspace |
| 49 | +To create an Azure Machine Learning workspace, use one of the following Terraform configurations. An Azure Machine Learning workspace requires various other services as dependencies. The template specifies these [associated resources](./concept-workspace.md#associated-resources). Depending on your needs, you can choose to use a template that creates resources with either public or private network connectivity. |
53 | 50 |
|
54 |
| -The following Terraform configurations can be used to create an Azure Machine Learning workspace. When you create an Azure Machine Learning workspace, various other services are required as dependencies. The template also specifies these [associated resources to the workspace](./concept-workspace.md#associated-resources). Depending on your needs, you can choose to use the template that creates resources with either public or private network connectivity. |
| 51 | +> [!NOTE] |
| 52 | +> Some resources in Azure require globally unique names. Before deploying your resources, make sure to set `name` variables to unique values. |
55 | 53 |
|
56 |
| -# [Public network connectivity](#tab/publicworkspace) |
| 54 | +# [Public network](#tab/publicworkspace) |
57 | 55 |
|
58 |
| -Some resources in Azure require globally unique names. Before deploying your resources using the following templates, set the `name` variable to a value that is unique. |
| 56 | +The following configuration creates a workspace with public network connectivity. |
| 57 | + |
| 58 | +Define the following variables in a file called *variables.tf*. |
59 | 59 |
|
60 |
| -**variables.tf**: |
61 | 60 | :::code language="terraform" source="~/terraform/quickstart/101-machine-learning/variables.tf":::
|
62 | 61 |
|
63 |
| -**workspace.tf**: |
| 62 | +Define the following workspace configuration in a file called *workspace.tf*: |
| 63 | + |
64 | 64 | :::code language="terraform" source="~/terraform/quickstart/101-machine-learning/workspace.tf":::
|
65 | 65 |
|
66 |
| -# [Private network connectivity](#tab/privateworkspace) |
| 66 | +# [Private network](#tab/privateworkspace) |
| 67 | + |
| 68 | +The following configuration creates a workspace in an isolated network environment by using Azure Private Link endpoints. The template includes [private Domain Name System (DNS) zones](../dns/private-dns-privatednszone.md) to resolve domain names within the virtual network. |
67 | 69 |
|
68 |
| -The configuration below creates a workspace in an isolated network environment using Azure Private Link endpoints. [Private DNS zones](../dns/private-dns-privatednszone.md) are included so domain names can be resolved within the virtual network. |
| 70 | +If you use private link endpoints for both Azure Container Registry and Azure Machine Learning, you can't use Container Registry tasks for building [environment](/python/api/azure-ai-ml/azure.ai.ml.entities.environment) images. Instead you must build images by using an Azure Machine Learning compute cluster. |
69 | 71 |
|
70 |
| -Some resources in Azure require globally unique names. Before deploying your resources using the following templates, set the `resourceprefix` variable to a value that is unique. |
| 72 | +To configure the cluster name to use, set the [image_build_compute_name](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/machine_learning_workspace) argument. You can also [allow public access](./how-to-configure-private-link.md?tabs=python#enable-public-access) to a workspace that has a private link endpoint by using the [public_network_access_enabled](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/machine_learning_workspace) argument. |
71 | 73 |
|
72 |
| -When using private link endpoints for both Azure Container Registry and Azure Machine Learning, Azure Container Registry tasks cannot be used for building [environment](/python/api/azure-ai-ml/azure.ai.ml.entities.environment) images. Instead you can build images using an Azure Machine Learning compute cluster. To configure the cluster name of use, set the [image_build_compute_name](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/machine_learning_workspace) argument. You can configure to [allow public access](./how-to-configure-private-link.md?tabs=python#enable-public-access) to a workspace that has a private link endpoint using the [public_network_access_enabled](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/machine_learning_workspace) argument. |
| 74 | +Define the following variables in a file called *variables.tf*. |
73 | 75 |
|
74 |
| -**variables.tf**: |
75 | 76 | :::code language="terraform" source="~/terraform/quickstart/201-machine-learning-moderately-secure/variables.tf":::
|
76 | 77 |
|
77 |
| -**workspace.tf**: |
| 78 | +Define the following workspace configuration in a file called *workspace.tf*: |
| 79 | + |
78 | 80 | :::code language="terraform" source="~/terraform/quickstart/201-machine-learning-moderately-secure/workspace.tf":::
|
79 | 81 |
|
80 |
| -**network.tf**: |
| 82 | +Define the following network configuration in a file called *network.tf*: |
| 83 | + |
81 | 84 | ```terraform
|
82 |
| -# Virtual Network |
| 85 | +# Virtual network |
83 | 86 | resource "azurerm_virtual_network" "default" {
|
84 | 87 | name = "vnet-${var.name}-${var.environment}"
|
85 | 88 | address_space = var.vnet_address_space
|
@@ -110,32 +113,42 @@ resource "azurerm_subnet" "snet-workspace" {
|
110 | 113 | address_prefixes = var.ml_subnet_address_space
|
111 | 114 | enforce_private_link_endpoint_network_policies = true
|
112 | 115 | }
|
113 |
| -
|
114 |
| -# ... |
115 |
| -# For full reference, see: https://github.com/Azure/terraform/blob/master/quickstart/201-machine-learning-moderately-secure/network.tf |
116 | 116 | ```
|
117 | 117 |
|
118 |
| -There are several options to connect to your private link endpoint workspace. To learn more about these options, refer to [Securely connect to your workspace](./how-to-secure-workspace-vnet.md#securely-connect-to-your-workspace). |
| 118 | +- For a full reference, see [201: Machine learning workspace, compute, and a set of network components for network isolation](https://github.com/Azure/terraform/blob/master/quickstart/201-machine-learning-moderately-secure/network.tf). |
| 119 | +- To learn more about how to connect to your private link endpoint workspace, see [Securely connect to your workspace](./how-to-secure-workspace-vnet.md#securely-connect-to-your-workspace). |
119 | 120 |
|
120 | 121 | ---
|
121 | 122 |
|
122 |
| -## Troubleshooting |
| 123 | +## Create and apply the plan |
| 124 | + |
| 125 | +To create the workspace, run the following code: |
| 126 | + |
| 127 | +```terraform |
| 128 | +terraform init |
| 129 | +
|
| 130 | +terraform plan \ |
| 131 | + # -var <any of the variables set in variables.tf> \ |
| 132 | + -out demo.tfplan |
| 133 | +
|
| 134 | +terraform apply "demo.tfplan" |
| 135 | +``` |
123 | 136 |
|
124 |
| -### Resource provider errors |
| 137 | +## Troubleshoot resource provider errors |
125 | 138 |
|
126 | 139 | [!INCLUDE [machine-learning-resource-provider](includes/machine-learning-resource-provider.md)]
|
127 | 140 |
|
128 |
| -## Next steps |
| 141 | +## Related resources |
129 | 142 |
|
130 |
| -* To learn more about Terraform support on Azure, see [Terraform on Azure documentation](/azure/developer/terraform/). |
131 |
| -* For details on the Terraform Azure provider and Machine Learning module, see [Terraform Registry Azure Resource Manager Provider](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/machine_learning_workspace). |
132 |
| -* To find "quick start" template examples for Terraform, see [Azure Terraform QuickStart Templates](https://github.com/Azure/terraform/tree/master/quickstart): |
| 143 | +- To learn more about Terraform support on Azure, see [Terraform on Azure documentation](/azure/developer/terraform/). |
| 144 | +- For details on the Terraform Azure provider and Machine Learning module, see [Terraform Registry Azure Resource Manager provider](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/machine_learning_workspace). |
| 145 | +- To find quickstart template examples for Terraform, see the following [Azure Terraform quickstart templates](https://github.com/Azure/terraform/tree/master/quickstart). |
133 | 146 |
|
134 |
| - * [101: Machine learning workspace and compute](https://github.com/Azure/terraform/tree/master/quickstart/101-machine-learning) – the minimal set of resources needed to get started with Azure Machine Learning. |
135 |
| - * [201: Machine learning workspace, compute, and a set of network components for network isolation](https://github.com/Azure/terraform/tree/master/quickstart/201-machine-learning-moderately-secure) – all resources that are needed to create a production-pilot environment for use with HBI data. |
136 |
| - * [202: Similar to 201, but with the option to bring existing network components.](https://github.com/Azure/terraform/tree/master/quickstart/202-machine-learning-moderately-secure-existing-VNet). |
137 |
| - * [301: Machine Learning workspace (Secure Hub and Spoke with Firewall)](https://github.com/azure/terraform/tree/master/quickstart/301-machine-learning-hub-spoke-secure). |
| 147 | + - [101: Machine learning workspace and compute](https://github.com/Azure/terraform/tree/master/quickstart/101-machine-learning) provides the minimal set of resources needed to get started with Azure Machine Learning. |
| 148 | + - [201: Machine learning workspace, compute, and a set of network components for network isolation](https://github.com/Azure/terraform/tree/master/quickstart/201-machine-learning-moderately-secure) provides all resources needed to create a production-pilot environment for use with high business impact (HBI) data. |
| 149 | + - [202: Similar to 201, but with the option to bring existing network components](https://github.com/Azure/terraform/tree/master/quickstart/202-machine-learning-moderately-secure-existing-VNet). |
| 150 | + - [301: Machine Learning workspace (secure hub and spoke with firewall)](https://github.com/azure/terraform/tree/master/quickstart/301-machine-learning-hub-spoke-secure). |
138 | 151 |
|
139 |
| -* To learn more about network configuration options, see [Secure Azure Machine Learning workspace resources using virtual networks (VNets)](./how-to-network-security-overview.md). |
140 |
| -* For alternative Azure Resource Manager template-based deployments, see [Deploy resources with Resource Manager templates and Resource Manager REST API](../azure-resource-manager/templates/deploy-rest.md). |
141 |
| -* For information on how to keep your Azure Machine Learning up to date with the latest security updates, see [Vulnerability management](concept-vulnerability-management.md). |
| 152 | +- To learn more about network configuration options, see [Secure Azure Machine Learning workspace resources using virtual networks](./how-to-network-security-overview.md). |
| 153 | +- For alternative Azure Resource Manager template-based deployments, see [Deploy resources with Resource Manager templates and Resource Manager REST API](/azure/azure-resource-manager/templates/deploy-rest). |
| 154 | +- For information on how to keep your Azure Machine Learning workspace up to date with the latest security updates, see [Vulnerability management](concept-vulnerability-management.md). |
0 commit comments