Example #1
0
        public override void ExecuteCmdlet()
        {
            if (ResourceGroupName != null && string.IsNullOrWhiteSpace(ResourceGroupName))
            {
                throw new PSArgumentNullException("ResourceGroupName");
            }

            if (JobName != null && string.IsNullOrWhiteSpace(JobName))
            {
                throw new PSArgumentNullException("JobName");
            }

            if (File != null && string.IsNullOrWhiteSpace(File))
            {
                throw new PSArgumentNullException("File");
            }

            string rawJsonContent = StreamAnalyticsClient.ReadJsonFileContent(this.TryResolvePath(File));

            Name = ResolveResourceName(rawJsonContent, Name, "Function");

            if (Name != null && string.IsNullOrWhiteSpace(Name))
            {
                throw new ArgumentException(Resources.FunctionNameCannotBeEmpty);
            }

            CreatePSFunctionParameter parameter = new CreatePSFunctionParameter
            {
                ResourceGroupName = ResourceGroupName,
                JobName           = JobName,
                FunctionName      = Name,
                RawJsonContent    = rawJsonContent,
                Force             = Force.IsPresent,
                ConfirmAction     = ConfirmAction
            };

            WriteObject(StreamAnalyticsClient.CreatePSFunction(parameter));
        }