コード例 #1
0
        public static void ProcessPipeObject(PSActivityLogAlertResource inputObject, out string resourceGroupName, out string activityLogAlertName)
        {
            if (string.IsNullOrWhiteSpace(inputObject.Id))
            {
                throw new PSArgumentException(message: "Activity log alert Id cannot be null", paramName: "ActivityLogAlert");
            }

            if (string.IsNullOrWhiteSpace(inputObject.Name))
            {
                throw new PSArgumentException(message: "Activity log alert Name cannot be null", paramName: "ActivityLogAlert");
            }

            activityLogAlertName = inputObject.Name;

            try
            {
                Management.Internal.Resources.Utilities.Models.ResourceIdentifier resourceIdentifier = new Management.Internal.Resources.Utilities.Models.ResourceIdentifier(inputObject.Id);

                // Retrieve only the resource group name from the Id
                resourceGroupName = resourceIdentifier.ResourceGroupName;
            }
            catch (System.ArgumentException ex)
            {
                throw new PSArgumentException(message: "Invalid activity log alert resource Id: " + ex.Message, paramName: "ActivityLogAlert");
            }
        }
コード例 #2
0
        public static void ProcessPipeObject(string resourceId, out string resourceGroupName, out string ruleName)
        {
            if (string.IsNullOrWhiteSpace(resourceId))
            {
                throw new PSArgumentException(message: "Log alert Id cannot be null", paramName: "LogAlert");
            }

            try
            {
                Management.Internal.Resources.Utilities.Models.ResourceIdentifier resourceIdentifier = new Management.Internal.Resources.Utilities.Models.ResourceIdentifier(resourceId);
                resourceGroupName = resourceIdentifier.ResourceGroupName;
                ruleName          = resourceIdentifier.ResourceName;
            }
            catch (System.ArgumentException ex)
            {
                throw new PSArgumentException(message: "Invalid log alert resource Id: " + ex.Message, paramName: "LogAlert");
            }
        }