protected override void ProcessRecord() { base.ProcessRecord(); if (!string.IsNullOrEmpty(this.Name)) { PSNetworkInterface networkInterface; if (ParameterSetName.Equals("ScaleSetNic")) { networkInterface = this.GetScaleSetNetworkInterface(this.ResourceGroupName, this.VirtualMachineScaleSetName, this.VirtualMachineIndex, this.Name); } else { networkInterface = this.GetNetworkInterface(this.ResourceGroupName, this.Name); } WriteObject(networkInterface); } else if (!string.IsNullOrEmpty(this.ResourceGroupName)) { var getNetworkInterfaceResponse = new MNM.NetworkInterfaceListResponse(); if (ParameterSetName.Equals("ScaleSetNic")) { getNetworkInterfaceResponse = this.NetworkInterfaceClient.ListVirtualMachineScaleSetNetworkInterfaces(this.ResourceGroupName, this.VirtualMachineScaleSetName); } else { getNetworkInterfaceResponse = this.NetworkInterfaceClient.List(this.ResourceGroupName); } var psNetworkInterfaces = new List <PSNetworkInterface>(); foreach (var nic in getNetworkInterfaceResponse.NetworkInterfaces) { var psNic = this.ToPsNetworkInterface(nic); psNic.ResourceGroupName = this.ResourceGroupName; psNetworkInterfaces.Add(psNic); } WriteObject(psNetworkInterfaces, true); } else { var getNetworkInterfaceResponse = this.NetworkInterfaceClient.ListAll(); var psNetworkInterfaces = new List <PSNetworkInterface>(); foreach (var nic in getNetworkInterfaceResponse.NetworkInterfaces) { var psNic = this.ToPsNetworkInterface(nic); psNic.ResourceGroupName = NetworkBaseCmdlet.GetResourceGroup(psNic.Id); psNetworkInterfaces.Add(psNic); } WriteObject(psNetworkInterfaces, true); } }
public override void Execute() { base.Execute(); MNM.SecurityGroupViewParameters properties = new MNM.SecurityGroupViewParameters(); properties.TargetResourceId = this.TargetVirtualMachineId; PSSecurityGroupViewResult securityGroupView = new PSSecurityGroupViewResult(); if (string.Equals(this.ParameterSetName, "SetByLocation", StringComparison.OrdinalIgnoreCase)) { var networkWatcher = this.GetNetworkWatcherByLocation(this.Location); if (networkWatcher == null) { throw new ArgumentException("There is no network watcher in location {0}", this.Location); } this.ResourceGroupName = NetworkBaseCmdlet.GetResourceGroup(networkWatcher.Id); this.NetworkWatcherName = networkWatcher.Name; securityGroupView = GetSecurityGroupView(this.ResourceGroupName, this.NetworkWatcherName, properties); } else if (string.Equals(this.ParameterSetName, "SetByResource", StringComparison.OrdinalIgnoreCase)) { securityGroupView = GetSecurityGroupView(this.NetworkWatcher.ResourceGroupName, this.NetworkWatcher.Name, properties); } else { securityGroupView = GetSecurityGroupView(this.ResourceGroupName, this.NetworkWatcherName, properties); } WriteObject(securityGroupView); }
public override void Execute() { base.Execute(); MNM.TopologyParameters parameters = new MNM.TopologyParameters(); parameters.TargetResourceGroupName = this.TargetResourceGroupName; PSTopology topology = new PSTopology(); if (string.Equals(this.ParameterSetName, "SetByLocation", StringComparison.OrdinalIgnoreCase)) { var networkWatcher = this.GetNetworkWatcherByLocation(this.Location); if (networkWatcher == null) { throw new ArgumentException("There is no network watcher in location {0}", this.Location); } this.ResourceGroupName = NetworkBaseCmdlet.GetResourceGroup(networkWatcher.Id); this.NetworkWatcherName = networkWatcher.Name; topology = GetTopology(this.ResourceGroupName, this.NetworkWatcherName, parameters); } else if (string.Equals(this.ParameterSetName, "SetByResource", StringComparison.OrdinalIgnoreCase)) { topology = GetTopology(this.NetworkWatcher.ResourceGroupName, this.NetworkWatcher.Name, parameters); } else { topology = GetTopology(this.ResourceGroupName, this.NetworkWatcherName, parameters); } WriteObject(topology); }
public override void Execute() { base.Execute(); if (!string.IsNullOrEmpty(this.Name)) { var crossConnection = this.GetExpressRouteCrossConnection(this.ResourceGroupName, this.Name); WriteObject(crossConnection); } else { IPage <ExpressRouteCrossConnection> crossConnectionPage; if (!string.IsNullOrEmpty(this.ResourceGroupName)) { crossConnectionPage = this.ExpressRouteCrossConnectionClient.ListByResourceGroup(this.ResourceGroupName); } else { crossConnectionPage = this.ExpressRouteCrossConnectionClient.List(); } // Get all resources by polling on next page link var crossConnectionList = ListNextLink <ExpressRouteCrossConnection> .GetAllResourcesByPollingNextLink(crossConnectionPage, this.ExpressRouteCrossConnectionClient.ListNext); var psCrossConnections = new List <PSExpressRouteCrossConnection>(); foreach (var crossConnection in crossConnectionList) { var psCrossConnection = this.ToPsExpressRouteCrossConnection(crossConnection); psCrossConnection.ResourceGroupName = NetworkBaseCmdlet.GetResourceGroup(crossConnection.Id); psCrossConnections.Add(psCrossConnection); } WriteObject(psCrossConnections, true); } }
public override void Execute() { base.Execute(); MNM.TroubleshootingParameters parameters = new MNM.TroubleshootingParameters(); parameters.TargetResourceId = this.TargetResourceId; parameters.StorageId = this.StorageId; parameters.StoragePath = this.StoragePath; PSTroubleshootingResult troubleshoot = new PSTroubleshootingResult(); if (string.Equals(this.ParameterSetName, "SetByLocation", StringComparison.OrdinalIgnoreCase)) { var networkWatcher = this.GetNetworkWatcherByLocation(this.Location); if (networkWatcher == null) { throw new ArgumentException("There is no network watcher in location {0}", this.Location); } this.ResourceGroupName = NetworkBaseCmdlet.GetResourceGroup(networkWatcher.Id); this.NetworkWatcherName = networkWatcher.Name; troubleshoot = GetTroubleshooting(this.ResourceGroupName, this.NetworkWatcherName, parameters); } else if (string.Equals(this.ParameterSetName, "SetByResource", StringComparison.OrdinalIgnoreCase)) { troubleshoot = GetTroubleshooting(this.NetworkWatcher.ResourceGroupName, this.NetworkWatcher.Name, parameters); } else { troubleshoot = GetTroubleshooting(this.ResourceGroupName, this.NetworkWatcherName, parameters); } WriteObject(troubleshoot); }
public override void Execute() { base.Execute(); if (!string.IsNullOrEmpty(this.Name)) { var vnet = this.GetVirtualNetwork(this.ResourceGroupName, this.Name, this.ExpandResource); WriteObject(vnet); } else { IPage <Microsoft.Azure.Management.Network.Models.VirtualNetwork> vnetPage; if (!string.IsNullOrEmpty(this.ResourceGroupName)) { vnetPage = this.VirtualNetworkClient.List(this.ResourceGroupName); } else { vnetPage = this.VirtualNetworkClient.ListAll(); } // Get all resources by polling on next page link var vnetList = ListNextLink <Microsoft.Azure.Management.Network.Models.VirtualNetwork> .GetAllResourcesByPollingNextLink(vnetPage, this.VirtualNetworkClient.ListNext); var psVnets = new List <PSVirtualNetwork>(); foreach (var virtualNetwork in vnetList) { var psVnet = this.ToPsVirtualNetwork(virtualNetwork); psVnet.ResourceGroupName = NetworkBaseCmdlet.GetResourceGroup(virtualNetwork.Id); psVnets.Add(psVnet); } WriteObject(psVnets, true); } }
public override void Execute() { base.Execute(); ConfirmAction( Properties.Resources.RemoveResourceMessage, this.PacketCaptureName, () => { if (string.Equals(this.ParameterSetName, "SetByLocation", StringComparison.OrdinalIgnoreCase)) { var networkWatcher = this.GetNetworkWatcherByLocation(this.Location); if (networkWatcher == null) { throw new ArgumentException("There is no network watcher in location {0}", this.Location); } this.ResourceGroupName = NetworkBaseCmdlet.GetResourceGroup(networkWatcher.Id); this.NetworkWatcherName = networkWatcher.Name; this.PacketCaptures.Delete(this.ResourceGroupName, this.NetworkWatcherName, this.PacketCaptureName); } else if (string.Equals(this.ParameterSetName, "SetByResource", StringComparison.OrdinalIgnoreCase)) { this.PacketCaptures.Delete(this.NetworkWatcher.ResourceGroupName, this.NetworkWatcher.Name, this.PacketCaptureName); } else { this.PacketCaptures.Delete(this.ResourceGroupName, this.NetworkWatcherName, this.PacketCaptureName); } if (PassThru) { WriteObject(true); } }); }
public override void Execute() { base.Execute(); if (!string.IsNullOrEmpty(this.Name)) { var routeTable = this.GetRouteTable(this.ResourceGroupName, this.Name, this.ExpandResource); WriteObject(routeTable); } else { IPage <RouteTable> routeTablePage; if (!string.IsNullOrEmpty(this.ResourceGroupName)) { routeTablePage = this.RouteTableClient.List(this.ResourceGroupName); } else { routeTablePage = this.RouteTableClient.ListAll(); } // Get all resources by polling on next page link var routeTableList = ListNextLink <RouteTable> .GetAllResourcesByPollingNextLink(routeTablePage, this.RouteTableClient.ListNext); var psRouteTables = new List <PSRouteTable>(); foreach (var routeTable in routeTableList) { var psRouteTable = this.ToPsRouteTable(routeTable); psRouteTable.ResourceGroupName = NetworkBaseCmdlet.GetResourceGroup(routeTable.Id); psRouteTables.Add(psRouteTable); } WriteObject(psRouteTables, true); } }
public override void Execute() { base.Execute(); if (ShouldGetByName(ResourceGroupName, Name)) { var circuit = this.GetExpressRouteCircuit(this.ResourceGroupName, this.Name); WriteObject(circuit); } else { IPage <ExpressRouteCircuit> circuitPage; if (ShouldListByResourceGroup(ResourceGroupName, Name)) { circuitPage = this.ExpressRouteCircuitClient.List(this.ResourceGroupName); } else { circuitPage = this.ExpressRouteCircuitClient.ListAll(); } // Get all resources by polling on next page link var circuitList = ListNextLink <ExpressRouteCircuit> .GetAllResourcesByPollingNextLink(circuitPage, this.ExpressRouteCircuitClient.ListNext); var psCircuits = new List <PSExpressRouteCircuit>(); foreach (var ExpressRouteCircuit in circuitList) { var psVnet = this.ToPsExpressRouteCircuit(ExpressRouteCircuit); psVnet.ResourceGroupName = NetworkBaseCmdlet.GetResourceGroup(ExpressRouteCircuit.Id); psCircuits.Add(psVnet); } WriteObject(TopLevelWildcardFilter(ResourceGroupName, Name, psCircuits), true); } }
public override void Execute() { base.Execute(); if (ShouldGetByName(ResourceGroupName, Name)) { var pls = this.GetPrivateLinkService(this.ResourceGroupName, this.Name, this.ExpandResource); WriteObject(pls); } else { IPage <PrivateLinkService> plsPage; if (ShouldListByResourceGroup(ResourceGroupName, Name)) { plsPage = this.PrivateLinkServiceClient.List(this.ResourceGroupName); } else { plsPage = this.PrivateLinkServiceClient.ListBySubscription(); } var plsList = ListNextLink <PrivateLinkService> .GetAllResourcesByPollingNextLink(plsPage, this.PrivateLinkServiceClient.ListNext); var psPLSs = new List <PSPrivateLinkService>(); foreach (var pls in plsList) { var psPls = this.ToPsPrivateLinkService(pls); psPls.ResourceGroupName = NetworkBaseCmdlet.GetResourceGroup(pls.Id); psPLSs.Add(psPls); } WriteObject(TopLevelWildcardFilter(ResourceGroupName, Name, psPLSs), true); } }
public override void ExecuteCmdlet() { base.ExecuteCmdlet(); if (ShouldGetByName(ResourceGroupName, Name)) { var azureFirewall = this.GetAzureFirewall(this.ResourceGroupName, this.Name); WriteObject(azureFirewall); } else { IPage <AzureFirewall> azureFirewallPage = ShouldListBySubscription(ResourceGroupName, Name) ? this.AzureFirewallClient.ListAll() : this.AzureFirewallClient.List(this.ResourceGroupName); // Get all resources by polling on next page link var azureFirewallResponseList = ListNextLink <AzureFirewall> .GetAllResourcesByPollingNextLink(azureFirewallPage, this.AzureFirewallClient.ListNext); var psAzureFirewalls = azureFirewallResponseList.Select(firewall => { var psAzureFirewall = this.ToPsAzureFirewall(firewall); psAzureFirewall.ResourceGroupName = NetworkBaseCmdlet.GetResourceGroup(firewall.Id); return(psAzureFirewall); }).ToList(); WriteObject(TopLevelWildcardFilter(ResourceGroupName, Name, psAzureFirewalls), true); } }
public override void ExecuteCmdlet() { base.ExecuteCmdlet(); if (!string.IsNullOrEmpty(this.Name)) { var azureFirewall = this.GetAzureFirewall(this.ResourceGroupName, this.Name); WriteObject(azureFirewall); } else { IPage <AzureFirewall> azureFirewallPage = string.IsNullOrEmpty(this.ResourceGroupName) ? this.AzureFirewallClient.ListAll() : this.AzureFirewallClient.List(this.ResourceGroupName); // Get all resources by polling on next page link var azureFirewallResponseLIst = ListNextLink <AzureFirewall> .GetAllResourcesByPollingNextLink(azureFirewallPage, this.AzureFirewallClient.ListNext); var psAzureFirewalls = azureFirewallResponseLIst.Select(firewall => { var psAzureFirewall = this.ToPsAzureFirewall(firewall); psAzureFirewall.ResourceGroupName = NetworkBaseCmdlet.GetResourceGroup(firewall.Id); return(psAzureFirewall); }).ToList(); WriteObject(psAzureFirewalls, true); } }
public override void Execute() { base.Execute(); string connectionMonitorName = this.Name; string resourceGroupName = string.Empty; string networkWatcherName = string.Empty; if (ParameterSetName.Contains("SetByResourceId")) { ConnectionMonitorDetails connectionMonitorDetails = new ConnectionMonitorDetails(); connectionMonitorDetails = this.GetConnectionMonitorDetails(this.ResourceId); connectionMonitorName = connectionMonitorDetails.ConnectionMonitorName; resourceGroupName = connectionMonitorDetails.ResourceGroupName; networkWatcherName = connectionMonitorDetails.NetworkWatcherName; } else if (ParameterSetName.Contains("SetByResource")) { resourceGroupName = this.NetworkWatcher.ResourceGroupName; networkWatcherName = this.NetworkWatcher.Name; } else if (ParameterSetName.Contains("SetByName")) { resourceGroupName = this.ResourceGroupName; networkWatcherName = this.NetworkWatcherName; } else { var networkWatcher = this.GetNetworkWatcherByLocation(this.Location); if (networkWatcher == null) { throw new ArgumentException("There is no network watcher in the specified location"); } resourceGroupName = NetworkBaseCmdlet.GetResourceGroup(networkWatcher.Id); networkWatcherName = networkWatcher.Name; } if (!string.IsNullOrEmpty(connectionMonitorName)) { PSConnectionMonitorResult connectionMonitor = new PSConnectionMonitorResult(); connectionMonitor = this.GetConnectionMonitor(resourceGroupName, networkWatcherName, connectionMonitorName); WriteObject(connectionMonitor); } else { List <PSConnectionMonitorResult> psConnectionMonitorList = new List <PSConnectionMonitorResult>(); var connectionMonitorList = this.ConnectionMonitors.List(resourceGroupName, networkWatcherName); foreach (var cm in connectionMonitorList) { PSConnectionMonitorResult psConnectionMonitor = NetworkResourceManagerProfile.Mapper.Map <PSConnectionMonitorResult>(cm); psConnectionMonitorList.Add(psConnectionMonitor); } WriteObject(psConnectionMonitorList, true); } }
public override void Execute() { base.Execute(); if (ShouldGetByName(ResourceGroupName, Name)) { var pe = this.GetPrivateEndpoint(this.ResourceGroupName, this.Name, this.ExpandResource); WriteObject(pe); } else { IPage <PrivateEndpoint> pePage; if (ShouldListByResourceGroup(ResourceGroupName, Name)) { pePage = this.PrivateEndpointClient.List(this.ResourceGroupName); } else { pePage = this.PrivateEndpointClient.ListBySubscription(); } var peList = ListNextLink <PrivateEndpoint> .GetAllResourcesByPollingNextLink(pePage, this.PrivateEndpointClient.ListNext); var psPEs = new List <PSPrivateEndpoint>(); foreach (var pe in peList) { var psPE = this.ToPsPrivateEndpoint(pe); psPE.ResourceGroupName = NetworkBaseCmdlet.GetResourceGroup(pe.Id); psPEs.Add(psPE); } WriteObject(TopLevelWildcardFilter(ResourceGroupName, Name, psPEs), true); } }
public override void ExecuteCmdlet() { base.ExecuteCmdlet(); if (!string.IsNullOrEmpty(this.Name)) { PSNetworkInterface networkInterface; if (ParameterSetName.Equals("ScaleSetNic")) { networkInterface = this.GetScaleSetNetworkInterface(this.ResourceGroupName, this.VirtualMachineScaleSetName, this.VirtualMachineIndex, this.Name); } else { networkInterface = this.GetNetworkInterface(this.ResourceGroupName, this.Name); } WriteObject(networkInterface); } else if (!string.IsNullOrEmpty(this.ResourceGroupName)) { IEnumerable <MNM.NetworkInterface> nicList; if (ParameterSetName.Equals("ScaleSetNic")) { nicList = this.NetworkInterfaceClient.ListVirtualMachineScaleSetNetworkInterfaces(this.ResourceGroupName, this.VirtualMachineScaleSetName); } else { nicList = this.NetworkInterfaceClient.List(this.ResourceGroupName); } var psNetworkInterfaces = new List <PSNetworkInterface>(); foreach (var nic in nicList) { var psNic = this.ToPsNetworkInterface(nic); psNic.ResourceGroupName = this.ResourceGroupName; psNetworkInterfaces.Add(psNic); } WriteObject(psNetworkInterfaces, true); } else { var nicList = this.NetworkInterfaceClient.ListAll(); var psNetworkInterfaces = new List <PSNetworkInterface>(); foreach (var nic in nicList) { var psNic = this.ToPsNetworkInterface(nic); psNic.ResourceGroupName = NetworkBaseCmdlet.GetResourceGroup(psNic.Id); psNetworkInterfaces.Add(psNic); } WriteObject(psNetworkInterfaces, true); } }
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; } else if (ParameterSetName.Contains("SetByInputObject")) { ResourceIdentifier flowLogInfo = new ResourceIdentifier(this.InputObject.Id); this.Name = flowLogInfo.ResourceName; this.ResourceGroupName = flowLogInfo.ResourceGroupName; string parent = flowLogInfo.ParentResource; string[] tokens = parent.Split(new[] { '/' }, StringSplitOptions.RemoveEmptyEntries); this.NetworkWatcherName = tokens[1]; } ConfirmAction( Properties.Resources.RemoveResourceMessage, this.Name, () => { this.FlowLogs.Delete(this.ResourceGroupName, this.NetworkWatcherName, this.Name); if (PassThru) { WriteObject(true); } }); }
public override void Execute() { base.Execute(); if (string.Equals(this.ParameterSetName, VirtualRouterParameterSetNames.ByVirtualRouterResourceId, StringComparison.OrdinalIgnoreCase)) { var resourceInfo = new ResourceIdentifier(ResourceId); ResourceGroupName = resourceInfo.ResourceGroupName; RouterName = resourceInfo.ResourceName; } string ipConfigName = "ipconfig1"; if (ShouldGetByName(ResourceGroupName, RouterName)) { var virtualHub = this.NetworkClient.NetworkManagementClient.VirtualHubs.Get(ResourceGroupName, RouterName); var virtualHubModel = NetworkResourceManagerProfile.Mapper.Map <CNM.PSVirtualHub>(virtualHub); virtualHubModel.ResourceGroupName = this.ResourceGroupName; virtualHubModel.Tag = TagsConversionHelper.CreateTagHashtable(virtualHub.Tags); AddBgpConnectionsToPSVirtualHub(virtualHub, virtualHubModel, ResourceGroupName, RouterName); AddIpConfigurtaionToPSVirtualHub(virtualHubModel, this.ResourceGroupName, RouterName, ipConfigName); var virtualRouterModel = new PSVirtualRouter(virtualHubModel); virtualRouterModel.Tag = TagsConversionHelper.CreateTagHashtable(virtualHub.Tags); WriteObject(virtualRouterModel, true); } else { IPage <VirtualHub> virtualHubPage; if (ShouldListByResourceGroup(ResourceGroupName, RouterName)) { virtualHubPage = this.NetworkClient.NetworkManagementClient.VirtualHubs.ListByResourceGroup(this.ResourceGroupName); } else { virtualHubPage = this.NetworkClient.NetworkManagementClient.VirtualHubs.List(); } var virtualHubList = ListNextLink <VirtualHub> .GetAllResourcesByPollingNextLink(virtualHubPage, this.NetworkClient.NetworkManagementClient.VirtualHubs.ListNext); List <PSVirtualRouter> virtualRouterList = new List <PSVirtualRouter>(); foreach (var virtualHub in virtualHubList) { RouterName = virtualHub.Name; var virtualHubModel = NetworkResourceManagerProfile.Mapper.Map <CNM.PSVirtualHub>(virtualHub); virtualHubModel.ResourceGroupName = NetworkBaseCmdlet.GetResourceGroup(virtualHub.Id); virtualHubModel.Tag = TagsConversionHelper.CreateTagHashtable(virtualHub.Tags); AddBgpConnectionsToPSVirtualHub(virtualHub, virtualHubModel, ResourceGroupName, RouterName); AddIpConfigurtaionToPSVirtualHub(virtualHubModel, this.ResourceGroupName, RouterName, ipConfigName); var virtualRouterModel = new PSVirtualRouter(virtualHubModel); virtualRouterModel.Tag = TagsConversionHelper.CreateTagHashtable(virtualHub.Tags); virtualRouterList.Add(virtualRouterModel); } WriteObject(virtualRouterList, true); } }
public override void Execute() { base.Execute(); connectionMonitorName = this.Name; if (ParameterSetName.Contains("SetByResourceId")) { ConnectionMonitorDetails connectionMonitorDetails = new ConnectionMonitorDetails(); connectionMonitorDetails = this.GetConnectionMonitorDetails(this.ResourceId); connectionMonitorName = connectionMonitorDetails.ConnectionMonitorName; resourceGroupName = connectionMonitorDetails.ResourceGroupName; networkWatcherName = connectionMonitorDetails.NetworkWatcherName; } else if (ParameterSetName.Contains("SetByResource")) { resourceGroupName = this.NetworkWatcher.ResourceGroupName; networkWatcherName = this.NetworkWatcher.Name; } else if (ParameterSetName.Contains("SetByName")) { resourceGroupName = this.ResourceGroupName; networkWatcherName = this.NetworkWatcherName; } else if (ParameterSetName.Contains("SetByInputObject")) { ConnectionMonitorDetails connectionMonitorDetails = new ConnectionMonitorDetails(); connectionMonitorDetails = this.GetConnectionMonitorDetails(this.InputObject.Id); connectionMonitorName = connectionMonitorDetails.ConnectionMonitorName; resourceGroupName = connectionMonitorDetails.ResourceGroupName; networkWatcherName = connectionMonitorDetails.NetworkWatcherName; } else { var networkWatcher = this.GetNetworkWatcherByLocation(this.Location); if (networkWatcher == null) { throw new ArgumentException("There is no network watcher in the specified location"); } resourceGroupName = NetworkBaseCmdlet.GetResourceGroup(networkWatcher.Id); networkWatcherName = networkWatcher.Name; } var present = this.IsConnectionMonitorPresent(resourceGroupName, networkWatcherName, connectionMonitorName); if (!present) { throw new ArgumentException(Microsoft.Azure.Commands.Network.Properties.Resources.ResourceNotFound); } var connectionMonitor = UpdateConnectionMonitor(); WriteObject(connectionMonitor); }
public override void Execute() { base.Execute(); MNM.ConnectivityParameters parameters = new MNM.ConnectivityParameters(); parameters.Source = new MNM.ConnectivitySource(); parameters.Source.ResourceId = this.SourceId; parameters.Source.Port = this.SourcePort; parameters.Destination = new MNM.ConnectivityDestination(); parameters.Destination.ResourceId = this.DestinationId; parameters.Destination.Address = this.DestinationAddress; parameters.Destination.Port = this.DestinationPort; if (this.ProtocolConfiguration != null && string.Equals(this.ProtocolConfiguration.Protocol, "Http", StringComparison.OrdinalIgnoreCase)) { IList <MNM.HTTPHeader> headers = new List <MNM.HTTPHeader>(); if (this.ProtocolConfiguration.Header != null) { foreach (DictionaryEntry entry in this.ProtocolConfiguration.Header) { headers.Add(new MNM.HTTPHeader((string)entry.Key, (string)entry.Value)); } } MNM.HTTPConfiguration httpConfiguration = new MNM.HTTPConfiguration(this.ProtocolConfiguration.Method, headers, this.ProtocolConfiguration.ValidStatusCode.OfType <int?>().ToList()); parameters.ProtocolConfiguration = new MNM.ProtocolConfiguration(httpConfiguration); } MNM.ConnectivityInformation result = new MNM.ConnectivityInformation(); if (string.Equals(this.ParameterSetName, "SetByLocation", StringComparison.OrdinalIgnoreCase)) { var networkWatcher = this.GetNetworkWatcherByLocation(this.Location); if (networkWatcher == null) { throw new ArgumentException("There is no network watcher in location {0}", this.Location); } this.ResourceGroupName = NetworkBaseCmdlet.GetResourceGroup(networkWatcher.Id); this.NetworkWatcherName = networkWatcher.Name; result = this.NetworkWatcherClient.CheckConnectivity(this.ResourceGroupName, this.NetworkWatcherName, parameters); } else if (string.Equals(this.ParameterSetName, "SetByResource", StringComparison.OrdinalIgnoreCase)) { result = this.NetworkWatcherClient.CheckConnectivity(this.NetworkWatcher.ResourceGroupName, this.NetworkWatcher.Name, parameters); } else { result = this.NetworkWatcherClient.CheckConnectivity(this.ResourceGroupName, this.NetworkWatcherName, parameters); } PSConnectivityInformation psResult = NetworkResourceManagerProfile.Mapper.Map <PSConnectivityInformation>(result); WriteObject(psResult); }
public override void Execute() { base.Execute(); string connectionMonitorName = this.Name; string resourceGroupName = this.ResourceGroupName; string networkWatcherName = this.NetworkWatcherName; if (ParameterSetName.Contains("SetByResourceId")) { ConnectionMonitorDetails connectionMonitorDetails = new ConnectionMonitorDetails(); connectionMonitorDetails = this.GetConnectionMonitorDetails(this.ResourceId); connectionMonitorName = connectionMonitorDetails.ConnectionMonitorName; resourceGroupName = connectionMonitorDetails.ResourceGroupName; networkWatcherName = connectionMonitorDetails.NetworkWatcherName; } else if (ParameterSetName.Contains("SetByResource")) { resourceGroupName = this.NetworkWatcher.ResourceGroupName; networkWatcherName = this.NetworkWatcher.Name; } else if (ParameterSetName.Contains("SetByInputObject")) { ConnectionMonitorDetails connectionMonitorDetails = new ConnectionMonitorDetails(); connectionMonitorDetails = this.GetConnectionMonitorDetails(this.InputObject.Id); connectionMonitorName = connectionMonitorDetails.ConnectionMonitorName; resourceGroupName = connectionMonitorDetails.ResourceGroupName; networkWatcherName = connectionMonitorDetails.NetworkWatcherName; } else if (ParameterSetName.Contains("SetByLocation")) { var networkWatcher = this.GetNetworkWatcherByLocation(this.Location); if (networkWatcher == null) { throw new ArgumentException("There is no network watcher in location {0}", this.Location); } resourceGroupName = NetworkBaseCmdlet.GetResourceGroup(networkWatcher.Id); networkWatcherName = networkWatcher.Name; } ConfirmAction( Properties.Resources.RemoveResourceMessage, connectionMonitorName, () => { this.ConnectionMonitors.Start(resourceGroupName, networkWatcherName, connectionMonitorName); if (PassThru) { WriteObject(true); } }); }
public override void Execute() { base.Execute(); string connectionMonitorName = this.Name; string resourceGroupName = string.Empty; string networkWatcherName = string.Empty; if (ParameterSetName.Contains("SetByResourceId")) { ConnectionMonitorDetails connectionMonitorDetails = new ConnectionMonitorDetails(); connectionMonitorDetails = this.GetConnectionMonitorDetails(this.ResourceId); connectionMonitorName = connectionMonitorDetails.ConnectionMonitorName; resourceGroupName = connectionMonitorDetails.ResourceGroupName; networkWatcherName = connectionMonitorDetails.NetworkWatcherName; } else if (ParameterSetName.Contains("SetByResource")) { resourceGroupName = this.NetworkWatcher.ResourceGroupName; networkWatcherName = this.NetworkWatcher.Name; } else if (ParameterSetName.Contains("SetByName")) { resourceGroupName = this.ResourceGroupName; networkWatcherName = this.NetworkWatcherName; } else if (ParameterSetName.Contains("SetByInputObject")) { ConnectionMonitorDetails connectionMonitorDetails = new ConnectionMonitorDetails(); connectionMonitorDetails = this.GetConnectionMonitorDetails(this.InputObject.Id); connectionMonitorName = connectionMonitorDetails.ConnectionMonitorName; resourceGroupName = connectionMonitorDetails.ResourceGroupName; networkWatcherName = connectionMonitorDetails.NetworkWatcherName; } else { var networkWatcher = this.GetNetworkWatcherByLocation(this.Location); if (networkWatcher == null) { throw new ArgumentException("There is no network watcher in the specified location"); } resourceGroupName = NetworkBaseCmdlet.GetResourceGroup(networkWatcher.Id); networkWatcherName = networkWatcher.Name; } MNM.ConnectionMonitorQueryResult queryResult = this.ConnectionMonitors.Query(resourceGroupName, networkWatcherName, connectionMonitorName); PSConnectionMonitorQueryResult psQueryResult = NetworkResourceManagerProfile.Mapper.Map <PSConnectionMonitorQueryResult>(queryResult); WriteObject(psQueryResult); }
public override void Execute() { base.Execute(); string connectionMonitorName = this.Name; string resourceGroupName = this.ResourceGroupName; string networkWatcherName = this.NetworkWatcherName; if (ParameterSetName.Contains("SetByResourceId")) { ConnectionMonitorDetails connectionMonitorDetails = new ConnectionMonitorDetails(); connectionMonitorDetails = this.GetConnectionMonitorDetails(this.ResourceId); connectionMonitorName = connectionMonitorDetails.ConnectionMonitorName; resourceGroupName = connectionMonitorDetails.ResourceGroupName; networkWatcherName = connectionMonitorDetails.NetworkWatcherName; } else if (ParameterSetName.Contains("SetByResource")) { resourceGroupName = this.NetworkWatcher.ResourceGroupName; networkWatcherName = this.NetworkWatcher.Name; } else if (ParameterSetName.Contains("SetByLocation")) { var networkWatcher = this.GetNetworkWatcherByLocation(this.Location); if (networkWatcher == null) { throw new PSArgumentException(Properties.Resources.NoNetworkWatcherFound); } resourceGroupName = NetworkBaseCmdlet.GetResourceGroup(networkWatcher.Id); networkWatcherName = networkWatcher.Name; } if (ShouldGetByName(resourceGroupName, connectionMonitorName)) { var connectionMonitor = this.GetConnectionMonitor(resourceGroupName, networkWatcherName, connectionMonitorName, true); WriteObject(connectionMonitor); } else { var connectionMonitorList = this.ConnectionMonitors.List(resourceGroupName, networkWatcherName); List <PSConnectionMonitorResult> psConnectionMonitorList = new List <PSConnectionMonitorResult>(); foreach (var connectionMonitor in connectionMonitorList) { psConnectionMonitorList.Add(ConvertConnectionMonitorResultV2ToPSFormat(connectionMonitor)); } WriteObject(SubResourceWildcardFilter(Name, psConnectionMonitorList), true); } }
public override void Execute() { base.Execute(); string resourceGroupName; string name; if (string.Equals(this.ParameterSetName, "SetByLocation", StringComparison.OrdinalIgnoreCase)) { var networkWatcher = this.GetNetworkWatcherByLocation(this.Location); if (networkWatcher == null) { throw new ArgumentException("There is no network watcher in location {0}", this.Location); } resourceGroupName = NetworkBaseCmdlet.GetResourceGroup(networkWatcher.Id); name = networkWatcher.Name; } else if (ParameterSetName.Contains("SetByResource")) { resourceGroupName = this.NetworkWatcher.ResourceGroupName; name = this.NetworkWatcher.Name; } else { resourceGroupName = this.ResourceGroupName; name = this.NetworkWatcherName; } ConfirmAction( Properties.Resources.CreatingResourceMessage, "FlowLogConfig", () => { MNM.FlowLogInformation parameters = new MNM.FlowLogInformation(); parameters.TargetResourceId = this.TargetResourceId; parameters.Enabled = this.EnableFlowLog; parameters.StorageId = this.StorageAccountId; if (this.EnableRetention == true || this.EnableRetention == false) { parameters.RetentionPolicy = new MNM.RetentionPolicyParameters(); parameters.RetentionPolicy.Enabled = this.EnableRetention; parameters.RetentionPolicy.Days = this.RetentionInDays; } PSFlowLog flowLog = new PSFlowLog(); flowLog = SetFlowLogConfig(resourceGroupName, name, parameters); WriteObject(flowLog); }); }
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); } }
public override void Execute() { base.Execute(); if (string.Equals(this.ParameterSetName, "SetByLocation", StringComparison.OrdinalIgnoreCase)) { var psNetworkWatcher = this.GetNetworkWatcherByLocation(this.Location); if (psNetworkWatcher == null) { throw new ArgumentException("There is no network watcher in location {0}", this.Location); } WriteObject(psNetworkWatcher); } else if (!string.IsNullOrEmpty(this.Name)) { PSNetworkWatcher psNetworkWatcher; psNetworkWatcher = this.GetNetworkWatcher(this.ResourceGroupName, this.Name); WriteObject(psNetworkWatcher); } else if (!string.IsNullOrEmpty(this.ResourceGroupName)) { var networkWatchersList = this.NetworkWatcherClient.List(this.ResourceGroupName); var psNetworkWatchers = new List <PSNetworkWatcher>(); foreach (var networkWatcher in networkWatchersList) { var psNetworkWatcher = this.ToPsNetworkWatcher(networkWatcher); psNetworkWatcher.ResourceGroupName = this.ResourceGroupName; psNetworkWatchers.Add(psNetworkWatcher); } WriteObject(psNetworkWatchers, true); } else { var networkWatchersList = this.NetworkWatcherClient.ListAll(); var psNetworkWatchers = new List <PSNetworkWatcher>(); foreach (var networkWatcher in networkWatchersList) { var psNetworkWatcher = this.ToPsNetworkWatcher(networkWatcher); psNetworkWatcher.ResourceGroupName = NetworkBaseCmdlet.GetResourceGroup(networkWatcher.Id); psNetworkWatchers.Add(psNetworkWatcher); } WriteObject(psNetworkWatchers, true); } }
public override void Execute() { base.Execute(); if (ParameterSetName.Contains(SetByResourceId)) { PopulateBaseParametersFromResourceID(this.ResourceId); } else if (ParameterSetName.Contains(SetByResource)) { this.ResourceGroupName = this.NetworkWatcher.ResourceGroupName; this.NetworkWatcherName = this.NetworkWatcher.Name; this.Location = this.NetworkWatcher.Location; } 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; } else if (ParameterSetName.Contains(SetByName)) { MNM.NetworkWatcher networkWatcher = this.NetworkClient.NetworkManagementClient.NetworkWatchers.Get(this.ResourceGroupName, this.NetworkWatcherName); this.Location = networkWatcher.Location; } else if (ParameterSetName.Contains(SetByInputObject)) { PopulateBaseParametersFromResourceID(this.InputObject.Id); PopulateRequestParametersFromInputObject(); } var present = this.IsFlowLogPresent(this.ResourceGroupName, this.NetworkWatcherName, this.Name); ConfirmAction( Force.IsPresent, string.Format(Properties.Resources.OverwritingResource, this.Name), Properties.Resources.CreatingResourceMessage, this.Name, () => { PSFlowLogResource flowLog = CreateFlowLog(); WriteObject(flowLog); }, () => present); }
public override void Execute() { base.Execute(); var present = NetworkBaseCmdlet.IsResourcePresent(() => GetAzureFirewallPolicy(this.ResourceGroupName, this.Name)); ConfirmAction( Force.IsPresent, string.Format(Properties.Resources.OverwritingResource, Name), Properties.Resources.CreatingResourceMessage, Name, () => WriteObject(this.CreateAzureFirewallPolicy()), () => present); }
public override void Execute() { base.Execute(); if (string.Equals(this.ParameterSetName, VirtualRouterParameterSetNames.ByVirtualRouterResourceId, StringComparison.OrdinalIgnoreCase)) { var resourceInfo = new ResourceIdentifier(ResourceId); ResourceGroupName = resourceInfo.ResourceGroupName; RouterName = resourceInfo.ResourceName; } if (ShouldGetByName(ResourceGroupName, RouterName)) { var vVirtualRouter = this.NetworkClient.NetworkManagementClient.VirtualRouters.Get(ResourceGroupName, RouterName); var vVirtualRouterModel = NetworkResourceManagerProfile.Mapper.Map <CNM.PSVirtualRouter>(vVirtualRouter); vVirtualRouterModel.ResourceGroupName = this.ResourceGroupName; vVirtualRouterModel.Tag = TagsConversionHelper.CreateTagHashtable(vVirtualRouter.Tags); AddPeeringsToPSVirtualRouter(vVirtualRouter, vVirtualRouterModel, ResourceGroupName, RouterName); WriteObject(vVirtualRouterModel, true); } else { IPage <VirtualRouter> vVirtualRouterPage; if (ShouldListByResourceGroup(ResourceGroupName, RouterName)) { vVirtualRouterPage = this.NetworkClient.NetworkManagementClient.VirtualRouters.ListByResourceGroup(this.ResourceGroupName); } else { vVirtualRouterPage = this.NetworkClient.NetworkManagementClient.VirtualRouters.List(); } var vVirtualRouterList = ListNextLink <VirtualRouter> .GetAllResourcesByPollingNextLink(vVirtualRouterPage, this.NetworkClient.NetworkManagementClient.VirtualRouters.ListNext); List <PSVirtualRouter> psVirtualRouterList = new List <PSVirtualRouter>(); foreach (var vVirtualRouter in vVirtualRouterList) { RouterName = vVirtualRouter.Name; var vVirtualRouterModel = NetworkResourceManagerProfile.Mapper.Map <CNM.PSVirtualRouter>(vVirtualRouter); vVirtualRouterModel.ResourceGroupName = NetworkBaseCmdlet.GetResourceGroup(vVirtualRouter.Id); vVirtualRouterModel.Tag = TagsConversionHelper.CreateTagHashtable(vVirtualRouter.Tags); AddPeeringsToPSVirtualRouter(vVirtualRouter, vVirtualRouterModel, ResourceGroupName, RouterName); psVirtualRouterList.Add(vVirtualRouterModel); } WriteObject(psVirtualRouterList, true); } }
public override void Execute() { base.Execute(); 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; } else if (ParameterSetName.Contains("SetByConnectionMonitorV2Object")) { if (string.IsNullOrEmpty(this.ConnectionMonitor.ResourceGroupName) || string.IsNullOrEmpty(this.ConnectionMonitor.NetworkWatcherName)) { throw new PSArgumentException(Properties.Resources.MissingBaseParametersInConnectionMonitor); } this.ResourceGroupName = this.ConnectionMonitor.ResourceGroupName; this.NetworkWatcherName = this.ConnectionMonitor.NetworkWatcherName; this.Name = this.ConnectionMonitor.Name; } var present = this.IsConnectionMonitorPresent(this.ResourceGroupName, this.NetworkWatcherName, this.Name); bool isConnectionMonitorV2 = ParameterSetName.Contains("V2") ? true : false; ConfirmAction( Force.IsPresent, string.Format(Properties.Resources.OverwritingResource, this.Name), Properties.Resources.CreatingResourceMessage, this.Name, () => { var connectionMonitor = CreateConnectionMonitor(this.ResourceGroupName, this.NetworkWatcherName, isConnectionMonitorV2); WriteObject(connectionMonitor); }, () => present); }
public override void Execute() { base.Execute(); if (this.IsParameterBound(c => c.ResourceId)) { var resourceIdentifier = new ResourceIdentifier(this.ResourceId); this.ResourceGroupName = resourceIdentifier.ResourceGroupName; this.Name = resourceIdentifier.ResourceName; } if (!string.IsNullOrEmpty(this.Name)) { PSPublicIpPrefix publicIpPrefix; publicIpPrefix = this.GetPublicIpPrefix(this.ResourceGroupName, this.Name); WriteObject(publicIpPrefix); } else { IPage <PublicIPPrefix> publicipprefixPage; if (!string.IsNullOrEmpty(this.ResourceGroupName)) { publicipprefixPage = this.PublicIpPrefixClient.List(this.ResourceGroupName); } else { publicipprefixPage = this.PublicIpPrefixClient.ListAll(); } // Get all resources by polling on next page link List <PublicIPPrefix> publicIPPrefixList; publicIPPrefixList = ListNextLink <PublicIPPrefix> .GetAllResourcesByPollingNextLink(publicipprefixPage, this.PublicIpPrefixClient.ListNext); var psPublicIpPrefixes = new List <PSPublicIpPrefix>(); // populate the publicIpPrefixes with the ResourceGroupName foreach (var publicIpPrefix in publicIPPrefixList) { var psPublicIpPrefix = this.ToPsPublicIpPrefix(publicIpPrefix); psPublicIpPrefix.ResourceGroupName = NetworkBaseCmdlet.GetResourceGroup(publicIpPrefix.Id); psPublicIpPrefixes.Add(psPublicIpPrefix); } WriteObject(psPublicIpPrefixes, true); } }