none
New-AzureRmResourceGroupDeployment fails with ParentResourceNotFound

    Question

  • Hello, I'm attempting to use PowerShell and an ARM template to create VMs inside labs, and getting the following error:

    New-AzureRmResourceGroupDeployment : 8:56:21 AM - Resource Microsoft.DevTestLab/labs/virtualMachines
    '***my existing dev test lab***/***my desired vm name***' failed with message '{
      "error": {
        "code": "ParentResourceNotFound",
        "message": "Can not perform requested operation on nested resource. Parent resource
    '***my existing dev test lab***' not found."
      }
    }'
    At ***my powershell script path***.ps1:77 char:1
    + New-AzureRmResourceGroupDeployment -ResourceGroupName $resourceGroupN ...
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : NotSpecified: (:) [New-AzureRmResourceGroupDeployment], Exception
        + FullyQualifiedErrorId : Microsoft.Azure.Commands.ResourceManager.Cmdlets.Implementation.NewAzureResourceGroupD
       eploymentCmdlet

    I grabbed the template from the Azure Portal under the DevTestLab | Add | Choose a base | View ARM Template, and am specifying non-defaulted parameters via New-AzureRmResourceGroupDeployment:

    New-AzureRmResourceGroupDeployment -ResourceGroupName $resourceGroupName -TemplateFile $templateFilePath -newVMName $ServerName
    

    I can see all the related resources in the Azure Resource Explorer:

    https://management.azure.com/subscriptions/**subscription**/resourceGroups/**rg**/providers/Microsoft.DevTestLab/labs/***my existing lab***?api-version=2016-05-15

    In the PowerShell script I include the Microsoft.DevTestLab resource provider:

    ProviderNamespace : Microsoft.DevTestLab
    RegistrationState : Registered
    ResourceTypes     : {labs, labs/virtualMachines, operations, locations...}
    Locations         : {Australia East, Australia Southeast, Brazil South, Canada East...}

    Finally my question: What am I missing?

    Thursday, October 20, 2016 3:59 PM

Answers

  • Hi,

    The resource group name provided in this line of the PS1 script:

    New-AzureRmResourceGroupDeployment -ResourceGroupName $resourceGroupName -TemplateFile $templateFilePath -newVMName $ServerName

     

    Should be the resource group name of the lab (VmsThatRunMondayThroughFridayRg833510).

    Please check and let us know if that solves your issue.

    Regards,

    Ashok

    • Proposed as answer by kratka Friday, November 11, 2016 5:00 PM
    • Marked as answer by kratka_eric_d Friday, November 11, 2016 5:01 PM
    Thursday, November 10, 2016 11:07 AM
    Moderator

All replies

  • Hi,

    Thank you for posting on the azure forums!

    Just to confirm have you created a lab first? Error message stating that lab/resource not found.

    Please try again by using the ARM templates available in Git and check if that makes any difference.

    You may need to recheck the template name in the PowerShell cmdlet which you are using.

    Please refer Deploy resources with Resource Manager templates and Azure PowerShell for more details on deploying resources.

     

    Regards,

    Ashok

    Friday, October 21, 2016 10:00 AM
    Moderator
  • Yes the lab existed before I executed the script to create the VM. I'll use the template you pointed me to and let you know. Thanks for your reply.
    Friday, October 21, 2016 6:00 PM
  • Thanks for your reply. Yes the lab existed before I executed the script to create the VM, and already contained other VMs. I used the template at https://raw.githubusercontent.com/Azure/azure-devtestlab/master/ARMTemplates/101-dtl-create-vm-username-pwd-galleryimage/azuredeploy.json which yielded the same error.
    Friday, October 21, 2016 8:11 PM
  • I suspected my existing lab name may be too long (VmsThatRunMondayThroughFriday) so I created another lab (VMs) and tried to create a VM in the new lab and got the same error:

    New-AzureRmResourceGroupDeployment : 2:19:35 PM - Resource Microsoft.DevTestLab/labs/virtualMachines 'VMs/integ-app'
    failed with message '{
      "error": {
        "code": "ParentResourceNotFound",
        "message": "Can not perform requested operation on nested resource. Parent resource 'VMs' not found."
      }
    }'
    At C:\vsts\Tool\DeploymentScripts\CreateAzureVMInDevTestLab.ps1:77 char:1
    + New-AzureRmResourceGroupDeployment -ResourceGroupName $resourceGroupN ...
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : NotSpecified: (:) [New-AzureRmResourceGroupDeployment], Exception
        + FullyQualifiedErrorId : Microsoft.Azure.Commands.ResourceManager.Cmdlets.Implementation.NewAzureResourceGroupD
       eploymentCmdlet

    Friday, October 21, 2016 8:23 PM
  • Hi,

    Thank you for the additional details.

    We are checking on the issue and will update as earliest.

    Appreciate your time and patience in this matter.

    Regards,

    Ashok

    Saturday, October 22, 2016 1:10 PM
    Moderator
  • Hi,

    Please share your subscription ID, Lab name and VM name to investigate further about the issue.

    You may send your details to my ID: V dash kuasho at Microsoft dot com

     

    Regards,

    Ashok

    Saturday, October 29, 2016 6:43 AM
    Moderator
  • Hi,

    Request you to share your subscription ID, Lab name and VM name to investigate further about the issue.

    You may send your details to my ID: V dash kuasho at Microsoft dot com

     

    Regards,

    Ashok

    Wednesday, November 2, 2016 4:43 AM
    Moderator
  • I sent you an email on 10/29 at 22:37 and resent it now.
    Saturday, November 5, 2016 5:07 AM
  • Hi,

    Thank you for the details.

    We are investigating on this with technical team and will respond as earliest.

    Appreciate your time and patience in this matter.

    Regards,

    Ashok


    Saturday, November 5, 2016 5:17 AM
    Moderator
  • Hi,

    We would request you to send your ARM template and PowerShell cmdlets via email as specified above in order to investigate more on this to find the root cause.

    Regards,

    Ashok

    Tuesday, November 8, 2016 10:48 AM
    Moderator
  • Sent. Thank you for continuing to investigate.
    Wednesday, November 9, 2016 5:11 AM
  • Hi,

    The resource group name provided in this line of the PS1 script:

    New-AzureRmResourceGroupDeployment -ResourceGroupName $resourceGroupName -TemplateFile $templateFilePath -newVMName $ServerName

     

    Should be the resource group name of the lab (VmsThatRunMondayThroughFridayRg833510).

    Please check and let us know if that solves your issue.

    Regards,

    Ashok

    • Proposed as answer by kratka Friday, November 11, 2016 5:00 PM
    • Marked as answer by kratka_eric_d Friday, November 11, 2016 5:01 PM
    Thursday, November 10, 2016 11:07 AM
    Moderator
  • Yes that works great! Thank you for your help.

    How could I have known that I need to supply the lab's resource group when creating a VM inside a lab, but I need to create a new resource group when I just create a vm?

    Thursday, November 10, 2016 10:05 PM
  • Hi Kratka,

    Look at the resource type of a Lab Virtual Machine: Microsoft.DevTestLab/labs/virtualMachines, as opposed to a standard Azure VM: Microsoft.Compute/virtualMachines

    Clearer still, let's check the ids of a Lab and a Lab VM. (One way to see the ID of a resource is by looking at the URL when navigating onto the resource's blade)

    Lab:  subscriptions/[subId]/resourcegroups/[resourceGroupName]/providers/microsoft.devtestlab/labs/[labName]
    LabVM:  subscriptions/[subId]/resourcegroups/[resourceGroupName]/providers/microsoft.devtestlab/labs/[labName]/virtualmachines/[vmName]

    That shows that a Lab VM is actually a child of a Lab. That is not the case for a standard Azure VM.

    Knowing that helps understanding the info we give during the deployment. Notice in the template that nowhere is a resource group mentioned, only a lab name and a VM name. How does Azure knows where to create that VM? To fully understand in which lab to create that Lab VM, Azure needs:

    • A subscription - Which it knows by the selected subscription when executing the deployment
    • A resource group - Which it gets from the deployment execution parameter ResourceGroupName
    • A lab name - Which is provided inside the template

    Hopefully that clears things up, let me know if you have further questions,
    Jonathan





    Friday, November 11, 2016 3:40 PM
  • Ok I understand that now, thank you. 

    My mistake was [partly] using the Azure portal to compare a VM vs. a lab VM and noticing the "owner" resource group being unique per VM. For example I have a lab named mylab and its resource group is mylabrg833510. That lab has a vm named mylabvm and its resource group is mylab-mylabvm-472176. I also have a non-lab vm named myvm with a resource group of myvm1913468911. If the lab vm lives inside the lab resource group I would have expected to see its resource group listed as mylabrg833510. Using the portal I also don't see lab VMs listed as resources inside the lab resource group.

    Now I know. Thanks.


    Friday, November 11, 2016 5:12 PM