private void NewDevSpacesControllerAction() { string devSpacesNotSupportedReason = String.Empty; WriteVerbose(string.Format(Resources.FetchCluster, TargetClusterName, TargetResourceGroupName)); ManagedCluster cluster = ContainerClient.ManagedClusters.Get(TargetResourceGroupName, TargetClusterName); if (!cluster.IsDevSpacesSupported(out devSpacesNotSupportedReason)) { throw new Exception(devSpacesNotSupportedReason); } WriteVerbose(string.Format(Resources.FetchClusterAccessProfile, TargetClusterName, TargetResourceGroupName)); ManagedClusterAccessProfile accessProfile = ContainerClient.ManagedClusters.GetAccessProfiles(TargetResourceGroupName, TargetClusterName, "clusterUser"); if (accessProfile == null || string.IsNullOrEmpty(accessProfile.KubeConfig)) { throw new Exception(String.Format(Resources.CanNotFetchKubeConfig, TargetClusterName)); } GenericResource resource = RmClient.Resources.Get(TargetResourceGroupName, "Microsoft.ContainerService", "", "managedClusters", TargetClusterName, "2018-03-31"); if (!resource.IsDevSpacesSupported(out devSpacesNotSupportedReason)) { throw new Exception(devSpacesNotSupportedReason); } Controller createControllerParam = cluster.GetNewDevSpaceControllerParam(accessProfile, resource.Properties); createControllerParam.Tags = TagsConversionHelper.CreateTagDictionary(Tag, true); WriteVerbose(string.Format(Resources.CreatingDevSpaces, Name, ResourceGroupName)); Controller controller = Client.Controllers.Create(ResourceGroupName, Name, createControllerParam); WriteObject(new PSController(controller)); }
public static Controller GetNewDevSpaceControllerParam(this ManagedCluster managedCluster, ManagedClusterAccessProfile accessProfile, dynamic armProperties) { var clusterLocation = managedCluster.Location; dynamic httpApplicationRouting = armProperties?.addonProfiles?.httpApplicationRouting; var clusterDnsZone = httpApplicationRouting?.config?.HTTPApplicationRoutingZoneName; var createParameters = new Controller() { Location = clusterLocation, Sku = new Azure.Management.DevSpaces.Models.Sku(), Tags = null, HostSuffix = clusterDnsZone, TargetContainerHostResourceId = managedCluster.Id, TargetContainerHostCredentialsBase64 = accessProfile.KubeConfig }; return(createParameters); }