I have a resource group that contains separately created DevTest lab and Virtual Network (VNet) using Bicep.
I can manually by using the Azure portal attach the VNet to the Devtest lab by:
- Go to Devtest lab
- Select "Configuration and policies"
- From the External resources menu, select "Virtual networks"
- Click "Add"
- Select the VNet
Is it possible to automate this process using Azure CLI? or any other alternative?
As I am adopting Azure DevOps pipelines to run (Bicep code) and adjust (Azure CLI) the resources automatically.
I am using ARM/Bicep template (Microsoft.Network/virtualNetworks@2021-02-01) for VNET, and (Microsoft.DevTestLab/labs@2018-09-15) for DevTest lab
If you are creating Vnet and Devtest lab separately then you can use the below Azure Quickstart Template from Github for creating a Devtestlab with existing vnet :
JSON ARM:
Outputs: I tested it on my environment and the results are as below:
Note: Unfortuantely, there are no commands to connect vnet and Devtestlabs using Azure CLI or Azure-Powershell.
BICEP ARM:
Outputs: