1

Using the Node.js SDK, I've created a user and a resource group. How can I now assign the user to the resource group as an owner?

Shui shengbao
  • 18,746
  • 3
  • 27
  • 45
Ben Hall
  • 1,927
  • 5
  • 25
  • 39

1 Answers1

1

You could refer to this example.

authzClient.roleAssignments.create(scope, assignmentGuid, roleCreateParams, function (err, roleAssignment, req, res) {
  if (err) {
    console.log('\nError occured while creating the roleAssignment: \n' + util.inspect(err, { depth: null }));
    return;
  }

According to your need, you need the example.

Owner role id is 8e3af657-a8ff-443c-a75c-2fe8c4bcb635.

scope should be like this /subscriptions/{subscription-id}/resourceGroups/myresourcegroup1.

Replace application id to your user object id.

Also, you could use Azure rest API to do this, please refer to this link.

Shui shengbao
  • 18,746
  • 3
  • 27
  • 45