/// <summary>
        /// Populates error action paramenter values to PSJobActionParams.
        /// </summary>
        /// <param name="errorActionType">Error action type e.g. http, https, storage etc</param>
        /// <returns>PSJobActionParams.</returns>
        internal PSJobActionParams GetErrorActionParamsValue(string errorActionType)
        {
            if (!string.IsNullOrWhiteSpace(errorActionType))
            {
                var jobErrorActionType = (SchedulerModels.JobActionType)Enum.Parse(typeof(SchedulerModels.JobActionType), errorActionType, ignoreCase: true);

                var jobErrorAction = new PSJobActionParams()
                {
                    JobActionType = jobErrorActionType,
                };

                switch(jobErrorActionType)
                {
                    case SchedulerModels.JobActionType.Http:
                    case SchedulerModels.JobActionType.Https:
                        var jobErrorActionAuthentication = new PSHttpJobAuthenticationParams()
                        {
                            HttpAuthType = this.JobDynamicParameters.ErrorActionHttpAuthenticationType,
                            ClientCertPfx = string.IsNullOrWhiteSpace(JobDynamicParameters.ErrorActionClientCertificatePfx) ? null : SchedulerUtility.GetCertData(this.ResolvePath(JobDynamicParameters.ErrorActionClientCertificatePfx), JobDynamicParameters.ErrorActionClientCertificatePassword),
                            ClientCertPassword = this.JobDynamicParameters.ErrorActionClientCertificatePassword,
                            Username = this.JobDynamicParameters.ErrorActionBasicUsername,
                            Password = this.JobDynamicParameters.ErrorActionBasicPassword,
                            Secret = this.JobDynamicParameters.ErrorActionOAuthSecret,
                            Tenant = this.JobDynamicParameters.ErrorActionOAuthTenant,
                            Audience = this.JobDynamicParameters.ErrorActionOAuthAudience,
                            ClientId = this.JobDynamicParameters.ErrorActionOAuthClientId
                        };

                        var httpJobErrorAction = new PSHttpJobActionParams()
                        {
                            RequestMethod = this.JobDynamicParameters.ErrorActionMethod,
                            Uri = this.JobDynamicParameters.ErrorActionUri,
                            RequestBody = this.JobDynamicParameters.ErrorActionRequestBody,
                            RequestHeaders = this.JobDynamicParameters.ErrorActionHeaders,
                            RequestAuthentication = jobErrorActionAuthentication
                        };

                        jobErrorAction.HttpJobAction = httpJobErrorAction;
                        break;

                    case SchedulerModels.JobActionType.StorageQueue:
                        var storageQueueErrorAction = new PSStorageJobActionParams()
                        {
                            StorageAccount = this.JobDynamicParameters.ErrorActionStorageAccount,
                            StorageQueueName = this.JobDynamicParameters.ErrorActionStorageQueue,
                            StorageSasToken = this.JobDynamicParameters.ErrorActionStorageSASToken,
                            StorageQueueMessage = this.JobDynamicParameters.ErrorActionQueueMessageBody,
                        };

                        jobErrorAction.StorageJobAction = storageQueueErrorAction;
                        break;

                    case SchedulerModels.JobActionType.ServiceBusQueue:
                        var serviceBusQueueErrorAction = GetServiceBusErrorActionParams();
                        serviceBusQueueErrorAction.QueueName = this.JobDynamicParameters.ErrorActionServiceBusQueueName;
                        jobErrorAction.ServiceBusAction = serviceBusQueueErrorAction;
                        break;

                    case SchedulerModels.JobActionType.ServiceBusTopic:
                        var serviceBusTopicErrorAction = GetServiceBusErrorActionParams();
                        serviceBusTopicErrorAction.TopicPath = this.JobDynamicParameters.ErrorActionServiceBusTopicPath;
                        jobErrorAction.ServiceBusAction = serviceBusTopicErrorAction;
                        break;
                }

                return jobErrorAction;
            }

            return null;
        }
        /// <summary>
        /// Executes the command.
        /// </summary>
        public override void ExecuteCmdlet()
        {
            base.ExecuteCmdlet();
            
            var storageJobAction = new PSStorageJobActionParams()
            {
                StorageAccount = this.StorageQueueAccount,
                StorageQueueMessage = this.StorageQueueMessage,
                StorageQueueName = this.StorageQueueName,
                StorageSasToken = this.StorageSASToken
            };

            var jobAction = new PSJobActionParams()
            {
                JobActionType = SchedulerModels.JobActionType.StorageQueue,
                StorageJobAction = storageJobAction
            };

            var jobRecurrence = new PSJobRecurrenceParams()
            {
                Interval = this.Interval,
                Frequency = this.Frequency,
                EndTime = this.EndTime,
                ExecutionCount = this.ExecutionCount
            };

            var jobParams = new PSJobParams()
            {
                ResourceGroupName = this.ResourceGroupName,
                JobCollectionName = this.JobCollectionName,
                JobName = this.JobName,
                JobState = this.JobState,
                StartTime = this.StartTime,
                JobAction = jobAction,
                JobRecurrence = jobRecurrence,
                JobErrorAction = this.GetErrorActionParamsValue(this.ErrorActionType)
            };

            this.ConfirmAction(
                processMessage: string.Format(Resources.NewStorageQueueJobResourceDescription, this.JobName),
                target: this.JobCollectionName,
                action: () =>
                {
                    this.WriteObject(this.SchedulerClient.CreateJob(jobParams));
                }
            );
        }
        /// <summary>
        /// Gets storage queue.
        /// </summary>
        /// <param name="storageActionParams">Storage queue action propertis specified via PowerShell.</param>
        /// <returns>StorageQueueMessage object.</returns>
        private StorageQueueMessage GetStorageQueue(PSStorageJobActionParams storageActionParams)
        {
            if (string.IsNullOrWhiteSpace(storageActionParams.StorageAccount) ||
                string.IsNullOrWhiteSpace(storageActionParams.StorageQueueMessage) ||
                string.IsNullOrWhiteSpace(storageActionParams.StorageQueueName) ||
                string.IsNullOrWhiteSpace(storageActionParams.StorageSasToken))
            {
                throw new PSManagement.PSArgumentException(Resources.SchedulerInvalidStorageQueue);
            }

            var storageQueue = new StorageQueueMessage()
            {
                Message = storageActionParams.StorageQueueMessage,
                QueueName = storageActionParams.StorageQueueName,
                SasToken = storageActionParams.StorageSasToken,
                StorageAccount = storageActionParams.StorageAccount,
            };

            return storageQueue;
        }