1
votes

I'm using this command:

New-AzureRmResourceLock -LockLevel CanNotDelete -LockName "labservertest1lock" -ResourceName "labservertest1" -ResourceType "Microsoft.ClassicCompute/virtualMachines/"

I'm getting this error:

New-AzureRmResourceLock : ResourceNotFound : The Resource 'Microsoft.ClassicCompute/virtualMachines/labservertest1' under resource group '' was not found. At line:1 char:1 + New-AzureRmResourceLock -LockLevel CanNotDelete -LockName "labservertest1lock" - ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : CloseError: (:) [New-AzureRmResourceLock], ErrorResponseMessageException + FullyQualifiedErrorId : ResourceNotFound,Microsoft.Azure.Commands.ResourceManager.Cmdlets.Implementation.NewAzur eResourceLockCmdlet

My Resource here:

Name : labservertest1 ResourceId : /subscriptions/276866f0-eb22-4696-9667-2f30d2801a3a/resourceGroups/altqalab/providers/Microsoft.Cla ssicCompute/virtualMachines/labservertest1 ResourceName : labservertest1 ResourceType : Microsoft.ClassicCompute/virtualMachines ResourceGroupName : altqalab Location : westeurope SubscriptionId : 276866f0-eb22-4696-9667-2f30d2801a3a

It seems to be a problem on the ResourseType Flag, what should be my ResourceType for a VM???

1

1 Answers

1
votes

I believe the reason you're getting this error is because you're not specifying the ResourceGroupName parameter (based on the error message)

New-AzureRmResourceLock : ResourceNotFound : The Resource 'Microsoft.ClassicCompute/virtualMachines/labservertest1' under resource group '' was not found.

Please try the following and see if that works:

New-AzureRmResourceLock -LockLevel CanNotDelete -LockName "labservertest1lock" -ResourceName "labservertest1" -ResourceType "Microsoft.ClassicCompute/virtualMachines/" -ResourceGroupName "altqalab"