private static string GetForwarderName(WebRole[] webRoles, WorkerRole[] workerRoles) { string forwarderName = null; WorkerRole workerForwarder = workerRoles.FirstOrDefault(r => r.Imports != null && r.Imports.Any(i => i.moduleName == "RemoteForwarder")); if (workerForwarder != null) { // a worker role has the forwarder forwarderName = workerForwarder.name; } else { WebRole webForwarder = webRoles.FirstOrDefault(r => r.Imports != null && r.Imports.Any(i => i.moduleName == "RemoteForwarder")); if (webForwarder != null) { // a web role has the forwarder forwarderName = webForwarder.name; } } return forwarderName; }
private static string GetForwarderName(WebRole[] webRoles, WorkerRole[] workerRoles) { string forwarderName = null; WorkerRole workerForwarder = workerRoles.FirstOrDefault(r => r.Imports != null && r.Imports.Any(i => i.moduleName == "RemoteForwarder")); if (workerForwarder != null) { // a worker role has the forwarder forwarderName = workerForwarder.name; } else { WebRole webForwarder = webRoles.FirstOrDefault(r => r.Imports != null && r.Imports.Any(i => i.moduleName == "RemoteForwarder")); if (webForwarder != null) { // a web role has the forwarder forwarderName = webForwarder.name; } else { // no role has the forwarder yet WorkerRole firstWorkerRole = workerRoles.FirstOrDefault(); if (firstWorkerRole != null) { firstWorkerRole.Imports = GeneralUtilities.Append(firstWorkerRole.Imports, new Import { moduleName = "RemoteForwarder" }); forwarderName = firstWorkerRole.name; } else // no worker role, use a web role { WebRole firstWebRole = webRoles.FirstOrDefault(); if (firstWebRole != null) { firstWebRole.Imports = GeneralUtilities.Append(firstWebRole.Imports, new Import { moduleName = "RemoteForwarder" }); forwarderName = firstWebRole.name; } else { throw new InvalidOperationException(Resources.EnableAzureRemoteDesktop_Enable_NoRoles); } } } } return forwarderName; }