public Uri Create() { string vhdname = String.Format("{0}-{1}-{2}-{3}.vhd", serviceName, roleName, DateTimeToString(), counter++); string blobEndpoint = currentStorage.BlobEndpoint.AbsoluteUri; return(new Uri(GeneralUtilities.EnsureTrailingSlash(GeneralUtilities.EnsureTrailingSlash(blobEndpoint) + containerName) + vhdname)); }
protected KuduRemoteClientBase( string serviceUrl, ICredentials credentials = null, HttpMessageHandler handler = null) { if (serviceUrl == null) { throw new ArgumentNullException("serviceUrl"); } ServiceUrl = GeneralUtilities.EnsureTrailingSlash(serviceUrl); Credentials = credentials; Client = HttpClientHelper.CreateClient(ServiceUrl, credentials, handler); }
public override void ExecuteCmdlet() { ConfirmAction("adding environment", Name, () => { var profileClient = new RMProfileClient(AzureRmProfileProvider.Instance.GetProfile <AzureRmProfile>()); var newEnvironment = new AzureEnvironment { Name = Name, OnPremise = EnableAdfsAuthentication }; newEnvironment.SetEndpoint(AzureEnvironment.Endpoint.PublishSettingsFileUrl, PublishSettingsFileUrl); newEnvironment.SetEndpoint(AzureEnvironment.Endpoint.ServiceManagement, ServiceEndpoint); newEnvironment.SetEndpoint(AzureEnvironment.Endpoint.ResourceManager, ResourceManagerEndpoint); newEnvironment.SetEndpoint(AzureEnvironment.Endpoint.ManagementPortalUrl, ManagementPortalUrl); newEnvironment.SetEndpoint(AzureEnvironment.Endpoint.StorageEndpointSuffix, StorageEndpoint); newEnvironment.SetEndpoint(AzureEnvironment.Endpoint.ActiveDirectory, ActiveDirectoryEndpoint != null ? GeneralUtilities.EnsureTrailingSlash(ActiveDirectoryEndpoint) : ActiveDirectoryEndpoint); newEnvironment.SetEndpoint(AzureEnvironment.Endpoint.ActiveDirectoryServiceEndpointResourceId, ActiveDirectoryServiceEndpointResourceId); newEnvironment.SetEndpoint(AzureEnvironment.Endpoint.Gallery, GalleryEndpoint); newEnvironment.SetEndpoint(AzureEnvironment.Endpoint.Graph, GraphEndpoint); newEnvironment.SetEndpoint(AzureEnvironment.Endpoint.AzureKeyVaultDnsSuffix, AzureKeyVaultDnsSuffix); newEnvironment.SetEndpoint(AzureEnvironment.Endpoint.AzureKeyVaultServiceEndpointResourceId, AzureKeyVaultServiceEndpointResourceId); newEnvironment.SetEndpoint(AzureEnvironment.Endpoint.TrafficManagerDnsSuffix, TrafficManagerDnsSuffix); newEnvironment.SetEndpoint(AzureEnvironment.Endpoint.SqlDatabaseDnsSuffix, SqlDatabaseDnsSuffix); newEnvironment.SetEndpoint(AzureEnvironment.Endpoint.AzureDataLakeAnalyticsCatalogAndJobEndpointSuffix , AzureDataLakeAnalyticsCatalogAndJobEndpointSuffix); newEnvironment.SetEndpoint(AzureEnvironment.Endpoint.AzureDataLakeStoreFileSystemEndpointSuffix, AzureDataLakeStoreFileSystemEndpointSuffix); newEnvironment.SetEndpoint(AzureEnvironment.Endpoint.AdTenant, AdTenant); newEnvironment.SetEndpoint(AzureEnvironment.Endpoint.GraphEndpointResourceId, GraphAudience); newEnvironment.SetEndpoint(AzureEnvironment.Endpoint.DataLakeEndpointResourceId, DataLakeAudience); WriteObject(new PSAzureEnvironment(profileClient.AddOrSetEnvironment(newEnvironment))); }); }
public override void ExecuteCmdlet() { ConfirmAction("adding environment", Name, () => { var profileClient = new RMProfileClient(AzureRmProfileProvider.Instance.Profile); var newEnvironment = new AzureEnvironment { Name = Name, OnPremise = EnableAdfsAuthentication }; newEnvironment.Endpoints[AzureEnvironment.Endpoint.PublishSettingsFileUrl] = PublishSettingsFileUrl; newEnvironment.Endpoints[AzureEnvironment.Endpoint.ServiceManagement] = ServiceEndpoint; newEnvironment.Endpoints[AzureEnvironment.Endpoint.ResourceManager] = ResourceManagerEndpoint; newEnvironment.Endpoints[AzureEnvironment.Endpoint.ManagementPortalUrl] = ManagementPortalUrl; newEnvironment.Endpoints[AzureEnvironment.Endpoint.StorageEndpointSuffix] = StorageEndpoint; newEnvironment.Endpoints[AzureEnvironment.Endpoint.ActiveDirectory] = ActiveDirectoryEndpoint != null ? GeneralUtilities.EnsureTrailingSlash(ActiveDirectoryEndpoint) : ActiveDirectoryEndpoint; newEnvironment.Endpoints[AzureEnvironment.Endpoint.ActiveDirectoryServiceEndpointResourceId] = ActiveDirectoryServiceEndpointResourceId; newEnvironment.Endpoints[AzureEnvironment.Endpoint.Gallery] = GalleryEndpoint; newEnvironment.Endpoints[AzureEnvironment.Endpoint.Graph] = GraphEndpoint; newEnvironment.Endpoints[AzureEnvironment.Endpoint.AzureKeyVaultDnsSuffix] = AzureKeyVaultDnsSuffix; newEnvironment.Endpoints[AzureEnvironment.Endpoint.AzureKeyVaultServiceEndpointResourceId] = AzureKeyVaultServiceEndpointResourceId; newEnvironment.Endpoints[AzureEnvironment.Endpoint.TrafficManagerDnsSuffix] = TrafficManagerDnsSuffix; newEnvironment.Endpoints[AzureEnvironment.Endpoint.SqlDatabaseDnsSuffix] = SqlDatabaseDnsSuffix; newEnvironment.Endpoints[AzureEnvironment.Endpoint.AzureDataLakeAnalyticsCatalogAndJobEndpointSuffix ] = AzureDataLakeAnalyticsCatalogAndJobEndpointSuffix; newEnvironment.Endpoints[AzureEnvironment.Endpoint.AzureDataLakeStoreFileSystemEndpointSuffix] = AzureDataLakeStoreFileSystemEndpointSuffix; newEnvironment.Endpoints[AzureEnvironment.Endpoint.AdTenant] = AdTenant; newEnvironment.Endpoints[AzureEnvironment.Endpoint.GraphEndpointResourceId] = GraphAudience; WriteObject((PSAzureEnvironment)profileClient.AddOrSetEnvironment(newEnvironment)); }); }
protected KuduRemoteClientBase( string serviceUrl, ICredentials credentials = null, HttpMessageHandler handler = null) { if (serviceUrl == null) { throw new ArgumentNullException("serviceUrl"); } ServiceUrl = GeneralUtilities.EnsureTrailingSlash(serviceUrl); Credentials = credentials; if (credentials != null) { Client = AzureSession.Instance.ClientFactory.CreateHttpClient(serviceUrl, ClientFactory.CreateHttpClientHandler(serviceUrl, credentials)); } else { Client = AzureSession.Instance.ClientFactory.CreateHttpClient(serviceUrl, handler); } }
public override void ExecuteCmdlet() { ConfirmAction("adding environment", Name, () => { if (AzureEnvironment.PublicEnvironments.Keys.Any((k) => string.Equals(k, Name, StringComparison.CurrentCultureIgnoreCase))) { throw new InvalidOperationException(string.Format(CultureInfo.CurrentCulture, "Cannot add built-in environment {0}.", Name)); } if (this.ParameterSetName.Equals(MetadataParameterSet, StringComparison.Ordinal)) { // Simply use built-in environments if the ARM endpoint matches the ARM endpoint for a built-in environment var publicEnvironment = AzureEnvironment.PublicEnvironments.FirstOrDefault( env => !string.IsNullOrWhiteSpace(ARMEndpoint) && string.Equals( env.Value?.GetEndpoint(AzureEnvironment.Endpoint.ResourceManager)?.ToLowerInvariant(), GeneralUtilities.EnsureTrailingSlash(ARMEndpoint)?.ToLowerInvariant(), StringComparison.CurrentCultureIgnoreCase)); var defProfile = GetDefaultProfile(); IAzureEnvironment newEnvironment; if (!defProfile.TryGetEnvironment(this.Name, out newEnvironment)) { newEnvironment = new AzureEnvironment { Name = this.Name }; } if (publicEnvironment.Key == null) { SetEndpointIfProvided(newEnvironment, AzureEnvironment.Endpoint.ResourceManager, ARMEndpoint); try { EnvHelper = (EnvHelper == null ? new EnvironmentHelper() : EnvHelper); MetadataResponse metadataEndpoints = EnvHelper.RetrieveMetaDataEndpoints(newEnvironment.ResourceManagerUrl).Result; string domain = EnvHelper.RetrieveDomain(ARMEndpoint); SetEndpointIfProvided(newEnvironment, AzureEnvironment.Endpoint.ActiveDirectory, metadataEndpoints.authentication.LoginEndpoint.TrimEnd('/') + '/'); SetEndpointIfProvided(newEnvironment, AzureEnvironment.Endpoint.ActiveDirectoryServiceEndpointResourceId, metadataEndpoints.authentication.Audiences[0]); SetEndpointIfProvided(newEnvironment, AzureEnvironment.Endpoint.Gallery, metadataEndpoints.GalleryEndpoint); SetEndpointIfProvided(newEnvironment, AzureEnvironment.Endpoint.Graph, metadataEndpoints.GraphEndpoint); SetEndpointIfProvided(newEnvironment, AzureEnvironment.Endpoint.GraphEndpointResourceId, metadataEndpoints.GraphEndpoint); SetEndpointIfProvided(newEnvironment, AzureEnvironment.Endpoint.AzureKeyVaultDnsSuffix, AzureKeyVaultDnsSuffix ?? string.Format("vault.{0}", domain).ToLowerInvariant()); SetEndpointIfProvided(newEnvironment, AzureEnvironment.Endpoint.AzureKeyVaultServiceEndpointResourceId, AzureKeyVaultServiceEndpointResourceId ?? string.Format("https://vault.{0}", domain).ToLowerInvariant()); SetEndpointIfProvided(newEnvironment, AzureEnvironment.Endpoint.StorageEndpointSuffix, StorageEndpoint ?? domain); newEnvironment.OnPremise = metadataEndpoints.authentication.LoginEndpoint.TrimEnd('/').EndsWith("/adfs", System.StringComparison.OrdinalIgnoreCase); } catch (AggregateException ae) { if (ae.Flatten().InnerExceptions.Count > 1) { throw; } if (ae.InnerException != null) { throw ae.InnerException; } } } else { newEnvironment = new AzureEnvironment(publicEnvironment.Value); newEnvironment.Name = Name; SetEndpointIfProvided(newEnvironment, AzureEnvironment.Endpoint.AzureKeyVaultDnsSuffix, AzureKeyVaultDnsSuffix); SetEndpointIfProvided(newEnvironment, AzureEnvironment.Endpoint.AzureKeyVaultServiceEndpointResourceId, AzureKeyVaultServiceEndpointResourceId); } ModifyContext((profile, client) => { WriteObject(new PSAzureEnvironment(client.AddOrSetEnvironment(newEnvironment))); }); } else { ModifyContext((profile, profileClient) => { IAzureEnvironment newEnvironment = new AzureEnvironment { Name = Name }; if (profile.EnvironmentTable.ContainsKey(Name)) { newEnvironment = profile.EnvironmentTable[Name]; } if (MyInvocation != null && MyInvocation.BoundParameters != null) { if (MyInvocation.BoundParameters.ContainsKey(nameof(EnableAdfsAuthentication))) { newEnvironment.OnPremise = EnableAdfsAuthentication; } SetEndpointIfBound(newEnvironment, AzureEnvironment.Endpoint.PublishSettingsFileUrl, nameof(PublishSettingsFileUrl)); SetEndpointIfBound(newEnvironment, AzureEnvironment.Endpoint.ServiceManagement, nameof(ServiceEndpoint)); SetEndpointIfBound(newEnvironment, AzureEnvironment.Endpoint.ResourceManager, nameof(ResourceManagerEndpoint)); SetEndpointIfBound(newEnvironment, AzureEnvironment.Endpoint.ManagementPortalUrl, nameof(ManagementPortalUrl)); SetEndpointIfBound(newEnvironment, AzureEnvironment.Endpoint.StorageEndpointSuffix, nameof(StorageEndpoint)); SetEndpointIfBound(newEnvironment, AzureEnvironment.Endpoint.ActiveDirectory, nameof(ActiveDirectoryEndpoint), true); SetEndpointIfBound(newEnvironment, AzureEnvironment.Endpoint.ActiveDirectoryServiceEndpointResourceId, nameof(ActiveDirectoryServiceEndpointResourceId)); SetEndpointIfBound(newEnvironment, AzureEnvironment.Endpoint.Gallery, nameof(GalleryEndpoint)); SetEndpointIfBound(newEnvironment, AzureEnvironment.Endpoint.Graph, nameof(GraphEndpoint)); SetEndpointIfBound(newEnvironment, AzureEnvironment.Endpoint.AzureKeyVaultDnsSuffix, nameof(AzureKeyVaultDnsSuffix)); SetEndpointIfBound(newEnvironment, AzureEnvironment.Endpoint.AzureKeyVaultServiceEndpointResourceId, nameof(AzureKeyVaultServiceEndpointResourceId)); SetEndpointIfBound(newEnvironment, AzureEnvironment.Endpoint.TrafficManagerDnsSuffix, nameof(TrafficManagerDnsSuffix)); SetEndpointIfBound(newEnvironment, AzureEnvironment.Endpoint.SqlDatabaseDnsSuffix, nameof(SqlDatabaseDnsSuffix)); SetEndpointIfBound(newEnvironment, AzureEnvironment.Endpoint.AzureDataLakeAnalyticsCatalogAndJobEndpointSuffix, nameof(AzureDataLakeAnalyticsCatalogAndJobEndpointSuffix)); SetEndpointIfBound(newEnvironment, AzureEnvironment.Endpoint.AzureDataLakeStoreFileSystemEndpointSuffix, nameof(AzureDataLakeStoreFileSystemEndpointSuffix)); SetEndpointIfBound(newEnvironment, AzureEnvironment.Endpoint.AdTenant, nameof(AdTenant)); SetEndpointIfBound(newEnvironment, AzureEnvironment.Endpoint.GraphEndpointResourceId, nameof(GraphAudience)); SetEndpointIfBound(newEnvironment, AzureEnvironment.Endpoint.DataLakeEndpointResourceId, nameof(DataLakeAudience)); SetEndpointIfBound(newEnvironment, AzureEnvironment.Endpoint.BatchEndpointResourceId, nameof(BatchEndpointResourceId)); SetEndpointIfBound(newEnvironment, AzureEnvironment.ExtendedEndpoint.OperationalInsightsEndpointResourceId, nameof(AzureOperationalInsightsEndpointResourceId)); SetEndpointIfBound(newEnvironment, AzureEnvironment.ExtendedEndpoint.OperationalInsightsEndpoint, nameof(AzureOperationalInsightsEndpoint)); WriteObject(new PSAzureEnvironment(profileClient.AddOrSetEnvironment(newEnvironment))); } }); } }); }