An Azure service that is used to provision Windows and Linux virtual machines.
The error that the path is not found when creating VMs with Azure PowerShell in a trial subscription is typically caused by one of these issues:
- The script is being run from a directory where the referenced files (template, parameters, or scripts) do not exist.
- The VM creation command is not using the built-in
New-AzVMflow that auto-creates resources, but instead expects existing files or configuration objects that were not created.
To validate and correct the setup using Azure PowerShell:
- Ensure the Azure PowerShell module is available and connected:
- Run
Get-Module -ListAvailable Azto confirm the Az module is installed. - Run
Connect-AzAccountif using local PowerShell.
- Run
- Confirm the working directory contains the files uploaded from GitHub:
- In the Azure Cloud Shell or local PowerShell, run
Get-ChildItemin the directory where the script is executed. - Verify that any referenced template or script files are present in that directory.
- In the Azure Cloud Shell or local PowerShell, run
- If the lab allows using
New-AzVMdirectly, create the VM and its resources in one step, which avoids path issues:- First create a resource group:
New-AzResourceGroup -Name 'myResourceGroup' -Location 'centralus' - Then create a VM (Windows example):
This command creates the VM and dependent resources (VNet, NIC, etc.) automatically if they do not exist.New-AzVM -ResourceGroupName 'myResourceGroup' -Location 'centralus'
- First create a resource group:
- If the lab uses an advanced configuration, ensure the VM configuration object and NIC are created before calling
New-AzVM:- Create the VM configuration and OS settings with
New-AzVMConfigandSet-AzVMOperatingSystem. - Attach a NIC created with
New-AzNetworkInterfaceusingAdd-AzVMNetworkInterface. - Finally create the VM:
New-AzVM -ResourceGroupName $myResourceGroup -Location $location -VM $vm
- Create the VM configuration and OS settings with
- If the lab uses a Resource Manager template, ensure the template path is correct:
- If using a local template, confirm the
-TemplateFilepath points to a file that exists in the current directory. - If using a template from a URL, ensure the script references that URL rather than a local path.
- If using a local template, confirm the
- Because this is a trial subscription, also verify that the region and VM size used in the script are available and supported:
- Create the resource group and VM in a supported region (for example,
EastUSorcentralus) as shown in the quickstart examples.
- Create the resource group and VM in a supported region (for example,
If the script still fails with “path not found,” adjust the script to either:
- Run from the directory where the uploaded files reside, or
- Use direct
New-AzVMcalls as shown above so that no external file paths are required.
References:
- Quickstart: Create a Windows virtual machine in Azure with PowerShell
- Quickstart: Create a Linux virtual machine in Azure with PowerShell
- Common PowerShell commands for creating and managing Azure Virtual Machines
- Create a virtual machine in an availability zone using Azure PowerShell
- Quickstart: Create and encrypt a Windows virtual machine in Azure with PowerShell
- Tutorial: Create Windows VM images with Azure PowerShell
- Create a Windows virtual machine from a Resource Manager template