/// <summary> /// Gets the id of the resource group from the resource id. /// </summary> /// <param name="resourceId">The resource id.</param> public static string GetResourceGroupId(string resourceId) { var subscriptionId = ResourceIdUtility.GetSubscriptionId(resourceId); if (string.IsNullOrWhiteSpace(subscriptionId)) { return(null); } Guid subscriptionGuid; if (!Guid.TryParse(subscriptionId, out subscriptionGuid)) { return(null); } var resourceGroupName = ResourceIdUtility.GetResourceGroupName(resourceId); if (string.IsNullOrWhiteSpace(resourceGroupName)) { return(null); } return(ResourceIdUtility.GetResourceId( subscriptionId: subscriptionGuid, resourceGroupName: resourceGroupName, resourceType: null, resourceName: null)); }