Skip to content

Commit 80c6749

Browse files
authored
Merge pull request #77002 from spelluru/labsnested0516
new article for nested template
2 parents 91821ef + 2391c79 commit 80c6749

File tree

5 files changed

+83
-2
lines changed

5 files changed

+83
-2
lines changed

articles/lab-services/TOC.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,8 @@
176176
href: integrate-environments-devops-pipeline.md
177177
- name: Use Platform-as-a-Service (PaaS) services
178178
href: use-paas-services.md
179+
- name: Deploy nested templates
180+
href: deploy-nested-template-environments.md
179181
- name: Secure access to labs
180182
items:
181183
- name: Add lab owners and users
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
---
2+
title: Deploy nested Resource Manager template environments in Azure DevTest Labs | Microsoft Docs
3+
description: Learn how to deploy nested Azure Resource Manager templates to provide environments with Azure DevTest Labs.
4+
services: devtest-lab,virtual-machines,lab-services
5+
documentationcenter: na
6+
author: spelluru
7+
manager: femila
8+
9+
ms.service: lab-services
10+
ms.workload: na
11+
ms.tgt_pltfrm: na
12+
ms.devlang: na
13+
ms.topic: article
14+
ms.date: 05/16/2019
15+
ms.author: spelluru
16+
17+
---
18+
19+
# Deploy nested Azure Resource Manager templates for testing environments
20+
A nested deployment allows you to execute other Azure Resource Manager templates from within a main Resource Manager template. It enables you to decompose your deployment into a set of targeted and purpose-specific templates. It provides benefits in terms of testing, reuse, and readability. The article [Using linked templates when deploying Azure resources](../azure-resource-manager/resource-group-linked-templates.md) provides a good overview of this solution with several code samples. This article provides an example that's specific to Azure DevTest Labs.
21+
22+
## Key parameters
23+
While you can create your own Resource Manager template from scratch, we recommend that you use the [Azure Resource Group project](../azure-resource-manager/vs-azure-tools-resource-groups-deployment-projects-create-deploy.md) in Visual Studio, which makes it easy to develop and debug templates. When you add a nested deployment resource to azuredeploy.json, Visual Studio adds several items to make the template more flexible. These items include the subfolder with the secondary template and parameters file, variable names within the main template file, and two parameters for the storage location for the new files. The **_artifactsLocation** and **_artifactsLocationSasToken** are the key parameters that the DevTest Labs uses.
24+
25+
If you aren't familiar with how the DevTest Labs works with environments, see [Create multi-VM environments and PaaS resources with Azure Resource Manager templates](devtest-lab-create-environment-from-arm.md). Your templates are stored in the repository linked to the lab in DevTest Labs. When you create a new environment with those templates, the files are moved into an Azure Storage container in the lab. To be able to identify and copy the nested files, DevTest Labs identifies the _artifactsLocation and _artifactsLocationSasToken parameters and copies the subfolders up to the storage container. Then, it automatically inserts the location and Shared Access Signature (SaS) token into parameters.
26+
27+
## Nested deployment example
28+
Here is a simple example of a nested deployment:
29+
30+
```json
31+
32+
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
33+
"contentVersion": "1.0.0.0",
34+
"parameters": {
35+
"_artifactsLocation": {
36+
"type": "string"
37+
},
38+
"_artifactsLocationSasToken": {
39+
"type": "securestring"
40+
}},
41+
"variables": {
42+
"NestOneTemplateFolder": "nestedtemplates",
43+
"NestOneTemplateFileName": "NestOne.json",
44+
"NestOneTemplateParametersFileName": "NestOne.parameters.json"},
45+
"resources": [
46+
{
47+
"name": "NestOne",
48+
"type": "Microsoft.Resources/deployments",
49+
"apiVersion": "2016-09-01",
50+
"dependsOn": [ ],
51+
"properties": {
52+
"mode": "Incremental",
53+
"templateLink": {
54+
"uri": "[concat(parameters('_artifactsLocation'), '/', variables('NestOneTemplateFolder'), '/', variables('NestOneTemplateFileName'), parameters('_artifactsLocationSasToken'))]",
55+
"contentVersion": "1.0.0.0"
56+
},
57+
"parametersLink": {
58+
"uri": "[concat(parameters('_artifactsLocation'), '/', variables('NestOneTemplateFolder'), '/', variables('NestOneTemplateParametersFileName'), parameters('_artifactsLocationSasToken'))]",
59+
"contentVersion": "1.0.0.0"
60+
}
61+
}
62+
}],
63+
"outputs": {}
64+
```
65+
66+
The folder in the repository containing this template has a subfolder `nestedtemplates` with the files **NestOne.json** and **NestOne.parameters.json**. In the **azuredeploy.json**, URI for the template is built using the artifacts location, nested template folder, nested template file name. Similarly, URI for the parameters is built using the artifacts location, nested template folder, and parameter file for the nested template.
67+
68+
Here is the image of the same project structure in Visual Studio:
69+
70+
![Project structure in Visual Studio](./media/deploy-nested-template-environments/visual-studio-project-structure.png)
71+
72+
You can add additional folders in the primary folder but not any deeper than a single level.
73+
74+
## Next steps
75+
See the following articles for details about environments:
76+
77+
- [Create multi-VM environments and PaaS resources with Azure Resource Manager templates](devtest-lab-create-environment-from-arm.md)
78+
- [Configure and use public environments in Azure DevTest Labs](devtest-lab-configure-use-public-environments.md)
79+
- [Connect an environment to your lab's virtual network in Azure DevTest Labs](connect-environment-lab-virtual-network.md)

articles/lab-services/devtest-lab-create-environment-from-arm.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ There are a couple of rules to follow to organize your Azure Resource Manager te
5050
![Key Azure Resource Manager template files](./media/devtest-lab-create-environment-from-arm/master-template.png)
5151

5252
- If you want to use parameter values defined in a parameter file, the parameter file must be named `azuredeploy.parameters.json`.
53-
- You can use the parameters `_artifactsLocation` and `_artifactsLocationSasToken` to construct the parametersLink URI value, allowing DevTest Labs to automatically manage nested templates. For more information, see [How Azure DevTest Labs makes nested Resource Manager template deployments easier for testing environments](https://blogs.msdn.microsoft.com/devtestlab/2017/05/23/how-azure-devtest-labs-makes-nested-arm-template-deployments-easier-for-testing-environments/).
53+
- You can use the parameters `_artifactsLocation` and `_artifactsLocationSasToken` to construct the parametersLink URI value, allowing DevTest Labs to automatically manage nested templates. For more information, see [Deploy nested Azure Resource Manager templates for testing environments](deploy-nested-template-environments.md).
5454
- Metadata can be defined to specify the template display name and description. This metadata must be in a file named `metadata.json`. The following example metadata file illustrates how to specify the display name and description:
5555

5656
```json
2.69 KB
Loading

articles/lab-services/use-paas-services.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ There's some custom lab information that is outside of the resource group and is
5050
The [Connecting environments to the lab's virtual network](connect-environment-lab-virtual-network.md) article describes how to modify your Resource Manager template to use the `$(LabSubnetId)` token. When an environment is created, the `$(LabSubnetId)` token is replaced by the first subnet mark where the **use in virtual machine create** option is set to **true**. It allows our environment to use previously created networks. If you want to use the same Resource Manager templates in environments in test as staging and production, use `$(LabSubnetId)` as a default value in a Resource Manager template parameter.
5151

5252
#### Environment Storage Account
53-
DevTest Labs supports the use of [nested Resource Manager templates](../azure-resource-manager/resource-group-linked-templates.md). The [How Azure DevTest Labs makes nested Resource Manager template deployments easier for testing environments](https://azure.microsoft.com/updates/azure-devtest-labs-streamlined-nested-arm-template-deployment-support-for-arm-template-based-environments) article explains how to use `_artifactsLocation` and `_artifactsLocationSasToken` tokens to create a URI to a Resource Manager template in the same folder as or in a nested folder of the main template. For more information about these two tokens, see the **Deployment artifacts** section of [Azure Resource Manager – Best Practices Guide](https://github.com/Azure/azure-quickstart-templates/blob/master/1-CONTRIBUTION-GUIDE/best-practices.md).
53+
DevTest Labs supports the use of [nested Resource Manager templates](../azure-resource-manager/resource-group-linked-templates.md). The [[Deploy nested Azure Resource Manager templates for testing environments](deploy-nested-template-environments.md) article explains how to use `_artifactsLocation` and `_artifactsLocationSasToken` tokens to create a URI to a Resource Manager template in the same folder as or in a nested folder of the main template. For more information about these two tokens, see the **Deployment artifacts** section of [Azure Resource Manager – Best Practices Guide](https://github.com/Azure/azure-quickstart-templates/blob/master/1-CONTRIBUTION-GUIDE/best-practices.md).
5454

5555
## User Experience
5656

0 commit comments

Comments
 (0)