GetResourceGroupName() public static method

Gets the name of the resource group from the resource id.
public static GetResourceGroupName ( string resourceId ) : string
resourceId string The resource id.
return string
        /// <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));
        }