|
14 | 14 |
|
15 | 15 | namespace Microsoft.Azure.Commands.Network
|
16 | 16 | {
|
| 17 | + using Gateway.Model; |
| 18 | + using Hyak.Common; |
| 19 | + using Microsoft.Azure.Common.Authentication; |
| 20 | + using Microsoft.Azure.Common.Authentication.Models; |
| 21 | + using Microsoft.WindowsAzure.Commands.ServiceManagement.Model; |
| 22 | + using Microsoft.WindowsAzure.Management.Compute; |
| 23 | + using NetworkSecurityGroup.Model; |
| 24 | + using Routes.Model; |
17 | 25 | using System;
|
18 | 26 | using System.Collections.Generic;
|
19 | 27 | using System.Linq;
|
20 | 28 | using System.Management.Automation;
|
21 |
| - using Gateway.Model; |
22 |
| - using NetworkSecurityGroup.Model; |
23 |
| - using Routes.Model; |
| 29 | + using System.Security.Cryptography.X509Certificates; |
24 | 30 | using WindowsAzure.Commands.Common.Storage;
|
25 | 31 | using WindowsAzure.Commands.Utilities.Common;
|
26 | 32 | using WindowsAzure.Management;
|
27 | 33 | using WindowsAzure.Management.Network;
|
28 | 34 | using WindowsAzure.Management.Network.Models;
|
29 | 35 | using WindowsAzure.Storage.Auth;
|
30 |
| - using Microsoft.Azure.Common.Authentication.Models; |
31 |
| - using Microsoft.Azure.Common.Authentication; |
32 |
| - using Hyak.Common; |
33 |
| - using System.Security.Cryptography.X509Certificates; |
34 |
| - using PowerShellAppGwModel = ApplicationGateway.Model; |
35 |
| - using Microsoft.WindowsAzure.Management.Compute; |
36 | 36 | using ComputeModels = Microsoft.WindowsAzure.Management.Compute.Models;
|
| 37 | + using PowerShellAppGwModel = ApplicationGateway.Model; |
37 | 38 |
|
38 | 39 | public class NetworkClient
|
39 | 40 | {
|
@@ -836,5 +837,46 @@ public void SetNetworkSecurityGroupForSubnet(string networkSecurityGroupName, st
|
836 | 837 |
|
837 | 838 | client.NetworkSecurityGroups.AddToSubnet(virtualNetworkName, subnetName, parameters);
|
838 | 839 | }
|
| 840 | + |
| 841 | + public string GetDeploymentBySlot(string serviceName, string slot) |
| 842 | + { |
| 843 | + if (string.IsNullOrEmpty(serviceName)) |
| 844 | + { |
| 845 | + throw new ArgumentNullException(serviceName); |
| 846 | + } |
| 847 | + |
| 848 | + if (string.IsNullOrEmpty(slot)) |
| 849 | + { |
| 850 | + throw new ArgumentNullException(slot); |
| 851 | + } |
| 852 | + |
| 853 | + var slotType = (ComputeModels.DeploymentSlot)Enum.Parse(typeof(ComputeModels.DeploymentSlot), slot, true); |
| 854 | + |
| 855 | + return this.computeClient.Deployments.GetBySlot( |
| 856 | + serviceName, |
| 857 | + slotType).Name; |
| 858 | + } |
| 859 | + |
| 860 | + public string GetDeploymentName(IPersistentVM vm, string slot, string serviceName) |
| 861 | + { |
| 862 | + string deploymentName = null; |
| 863 | + var vmRoleContext = vm as PersistentVMRoleContext; |
| 864 | + if (vmRoleContext != null) |
| 865 | + { |
| 866 | + deploymentName = vmRoleContext.DeploymentName; |
| 867 | + } |
| 868 | + |
| 869 | + if (string.IsNullOrEmpty(slot) && string.IsNullOrEmpty(deploymentName)) |
| 870 | + { |
| 871 | + slot = DeploymentSlotType.Production; |
| 872 | + } |
| 873 | + |
| 874 | + if (string.IsNullOrEmpty(deploymentName)) |
| 875 | + { |
| 876 | + deploymentName = this.GetDeploymentBySlot(serviceName, slot); |
| 877 | + } |
| 878 | + |
| 879 | + return deploymentName; |
| 880 | + } |
839 | 881 | }
|
840 | 882 | }
|
0 commit comments