Edit

Share via


Quickstart: Add resources or resource containers to service groups with Service Group Member Relationships

To add resources, resource groups, or subscriptions to a Service Group (preview), you need to create a new Service Group Member Relationship. For more information on service groups, see Getting started with Service Groups.

Important

Azure Service Groups is currently in public preview. See the Supplemental Terms of Use for Microsoft Azure Previews for legal terms that apply to Azure features that are in beta, preview, or otherwise not yet released into general availability.

Prerequisites

  • If you don't have an Azure subscription, create a free account before you begin.

  • If you haven't already, install ARMClient. It's a tool that sends HTTP requests to Azure Resource Manager-based REST APIs.

  • To be able to deploy a service group member relationship, you must have Microsoft.Relationship/ServiceGroupMember/write permissions on the source as well as Microsoft.ServiceGroup Contributor at the target service group.

Create in REST API

The [scope] in the URLs below refers to the full Azure Resource Manager path of the resource you want to add as a member. The scope varies depending on the type of resource:

Resource type Scope format
Subscription subscriptions/{subscriptionId}
Resource group subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}
Resource subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProvider}/{resourceType}/{resourceName}

For REST API, use the Service Groups Member - Create or Update endpoint to create a new service group member.

In this example, we're adding a Virtual Machine [VM1] to a service group [Contoso].

  1. Service Group: groupId is Contoso
  2. Virtual Machine: The resourceID is VM1
  3. Service Group Member: The relationshipID is SGM1

When you're adding a resource to a service group, you create service group member by extending the resource.

  • REST API URI

    PUT https://management.azure.com/[scope]/providers/Microsoft.Relationships/serviceGroupMember/SGM1?api-version=2023-09-01-preview
    

In the preceding example, the new service group member is created extending the Virtual Machine. To specify the service group as the parent, use the TargetID property.

  • REST API URI

    PUT https://management.azure.com/subscriptions/[SUBID]/resourceGroups/[RGID]/providers/microsoft.compute/virtualmachine/[VMID]/providers/Microsoft.Relationships/serviceGroupMember/SGM1?api-version=2023-09-01-preview
    
  • Request Body

      {
        "properties": {
         "targetId": "providers/microsoft.management/servicegroups/Contoso"
        }
      }
    

Clean up resources

To remove the service group created in this document, use the Service Group Member - Delete endpoint:

  • REST API URI

    DELETE https://management.azure.com/[scope]/providers/Microsoft.Relationships/serviceGroupMember/SGM1?api-version=2023-09-01-preview
    
  • No Request Body

Verify your service group member

The Create Service Group Member API is an asynchronous call. A successful response means the request was accepted, but the operation may still be processing. To check the operation status:

  1. Look for the Azure-AsyncOperation header in the response from the PUT request.
  2. Make a GET request to the URL in that header to check the operation status.
{
    "status": "Succeeded"
}

Possible status values include Succeeded, Failed, and InProgress. Wait for the operation to complete before relying on the membership relationship.

For more information on checking operation status, see Checking for Service Group Operation Status.

Next step

In this quickstart, you created a service group to help create different views in Azure. The service group can have member subscriptions, resource groups, resources, or other service groups.

To learn more about service groups and how to manage your service group hierarchy, continue to: