I have a simple code that creates ContainerGroup:
ContainerGroup instance = azure.containerGroups()
<truncated>
.create();
After instance has been created I would like to create delete lock:
azure.managementLocks().define("preventDelete").withLockedResource(instance).withLevel(LockLevel.CAN_NOT_DELETE).create();
The lock is never created failing with following error:
Status code 403, {"error":{"code":"AuthorizationFailed","message":"The client '' with object id '' does not have authorization to perform action 'Microsoft.Authorization/locks/write' over scope '/subscriptions//resourceGroups//providers/Microsoft.ContainerInstance/containerGroups//providers/Microsoft.Authorization/locks/preventDelete' or the scope is invalid. If access was recently granted, please refresh your credentials."}}
Works flawlessly using Azure UI. Any ideas?