예제 #1
0
        private PSFlowLogResource CreateFlowLog()
        {
            this.ValidateFlowLogParameters(this.TargetResourceId, this.StorageId, this.FormatVersion, this.FormatType, this.EnableTrafficAnalytics == true,
                                           this.TrafficAnalyticsWorkspaceId, this.TrafficAnalyticsInterval, this.RetentionPolicyDays);

            MNM.FlowLog flowLogParameters = GetFlowLogParametersFromRequest();

            this.FlowLogs.CreateOrUpdate(this.ResourceGroupName, this.NetworkWatcherName, this.Name, flowLogParameters);
            MNM.FlowLog flowLogResult = this.FlowLogs.Get(this.ResourceGroupName, this.NetworkWatcherName, this.Name);

            return(NetworkResourceManagerProfile.Mapper.Map <PSFlowLogResource>(flowLogResult));
        }
예제 #2
0
        public override void Execute()
        {
            base.Execute();

            if (ParameterSetName.Contains("SetByResourceId"))
            {
                ResourceIdentifier flowLogInfo = new ResourceIdentifier(this.ResourceId);

                this.Name = flowLogInfo.ResourceName;
                this.ResourceGroupName = flowLogInfo.ResourceGroupName;

                string   parent = flowLogInfo.ParentResource;
                string[] tokens = parent.Split(new[] { '/' }, StringSplitOptions.RemoveEmptyEntries);

                this.NetworkWatcherName = tokens[1];
            }
            else if (ParameterSetName.Contains("SetByResource"))
            {
                this.ResourceGroupName  = this.NetworkWatcher.ResourceGroupName;
                this.NetworkWatcherName = this.NetworkWatcher.Name;
            }
            else if (ParameterSetName.Contains("SetByLocation"))
            {
                var networkWatcher = this.GetNetworkWatcherByLocation(this.Location);

                if (networkWatcher == null)
                {
                    throw new PSArgumentException(Properties.Resources.NoNetworkWatcherFound);
                }

                this.ResourceGroupName  = NetworkBaseCmdlet.GetResourceGroup(networkWatcher.Id);
                this.NetworkWatcherName = networkWatcher.Name;
            }

            if (ShouldGetByName(this.ResourceGroupName, this.Name))
            {
                MNM.FlowLog flowLogResult = this.FlowLogs.Get(this.ResourceGroupName, this.NetworkWatcherName, this.Name);
                WriteObject(NetworkResourceManagerProfile.Mapper.Map <PSFlowLogResource>(flowLogResult));
            }
            else
            {
                var flowLogResults = this.FlowLogs.List(this.ResourceGroupName, this.NetworkWatcherName);

                List <PSFlowLogResource> flowLogs = new List <PSFlowLogResource>();
                foreach (var flowLogResult in flowLogResults)
                {
                    flowLogs.Add(NetworkResourceManagerProfile.Mapper.Map <PSFlowLogResource>(flowLogResult));
                }

                WriteObject(SubResourceWildcardFilter(this.Name, flowLogs), true);
            }
        }