本文整理汇总了C#中Microsoft.Azure.Common.Authentication.Models.AzureEnvironment.IsEndpointSet方法的典型用法代码示例。如果您正苦于以下问题:C# AzureEnvironment.IsEndpointSet方法的具体用法?C# AzureEnvironment.IsEndpointSet怎么用?C# AzureEnvironment.IsEndpointSet使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.Azure.Common.Authentication.Models.AzureEnvironment
的用法示例。
在下文中一共展示了AzureEnvironment.IsEndpointSet方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ListServiceManagementSubscriptions
private IEnumerable<AzureSubscription> ListServiceManagementSubscriptions(AzureAccount account, AzureEnvironment environment, SecureString password, ShowDialog promptBehavior, string[] tenants)
{
List<AzureSubscription> result = new List<AzureSubscription>();
if (!environment.IsEndpointSet(AzureEnvironment.Endpoint.ServiceManagement))
{
return result;
}
foreach (var tenant in tenants)
{
try
{
var tenantAccount = new AzureAccount();
CopyAccount(account, tenantAccount);
var tenantToken = AzureSession.AuthenticationFactory.Authenticate(tenantAccount, environment, tenant, password, ShowDialog.Never);
if (string.Equals(tenantAccount.Id, account.Id, StringComparison.InvariantCultureIgnoreCase))
{
tenantAccount = account;
}
tenantAccount.SetOrAppendProperty(AzureAccount.Property.Tenants, new string[] { tenant });
using (var subscriptionClient = AzureSession.ClientFactory.CreateCustomClient<SubscriptionClient>(
new TokenCloudCredentials(tenantToken.AccessToken),
environment.GetEndpointAsUri(AzureEnvironment.Endpoint.ServiceManagement)))
{
var subscriptionListResult = subscriptionClient.Subscriptions.List();
foreach (var subscription in subscriptionListResult.Subscriptions)
{
// only add the subscription if it's actually in this tenant
if (subscription.ActiveDirectoryTenantId == tenant)
{
AzureSubscription psSubscription = new AzureSubscription
{
Id = new Guid(subscription.SubscriptionId),
Name = subscription.SubscriptionName,
Environment = environment.Name
};
psSubscription.SetProperty(AzureSubscription.Property.Tenants,
subscription.ActiveDirectoryTenantId);
psSubscription.Account = tenantAccount.Id;
tenantAccount.SetOrAppendProperty(AzureAccount.Property.Subscriptions,
new string[] { psSubscription.Id.ToString() });
result.Add(psSubscription);
}
}
}
AddOrSetAccount(tenantAccount);
}
catch (CloudException cEx)
{
WriteOrThrowAadExceptionMessage(cEx);
}
catch (AadAuthenticationException aadEx)
{
WriteOrThrowAadExceptionMessage(aadEx);
}
}
return result;
}
示例2: PSAzureEnvironment
/// <summary>
/// Initializes a new Azure environment from the given internal representation.
/// </summary>
/// <param name="environment">The internal representation of the environment.</param>
public PSAzureEnvironment(AzureEnvironment environment)
{
Name = environment.Name;
EnableAdfsAuthentication = environment.OnPremise;
if (environment.IsEndpointSet(AzureEnvironment.Endpoint.ActiveDirectoryServiceEndpointResourceId))
{
ActiveDirectoryServiceEndpointResourceId =
environment.Endpoints[AzureEnvironment.Endpoint.ActiveDirectoryServiceEndpointResourceId];
}
if (environment.IsEndpointSet(AzureEnvironment.Endpoint.AdTenant))
{
AdTenant = environment.Endpoints[AzureEnvironment.Endpoint.AdTenant];
}
if (environment.IsEndpointSet(AzureEnvironment.Endpoint.Gallery))
{
GalleryUrl =
environment.Endpoints[AzureEnvironment.Endpoint.Gallery];
}
if (environment.IsEndpointSet(AzureEnvironment.Endpoint.ManagementPortalUrl))
{
ManagementPortalUrl =
environment.Endpoints[AzureEnvironment.Endpoint.ManagementPortalUrl];
}
if (environment.IsEndpointSet(AzureEnvironment.Endpoint.ServiceManagement))
{
ServiceManagementUrl =
environment.Endpoints[AzureEnvironment.Endpoint.ServiceManagement];
}
if (environment.IsEndpointSet(AzureEnvironment.Endpoint.PublishSettingsFileUrl))
{
PublishSettingsFileUrl =
environment.Endpoints[AzureEnvironment.Endpoint.PublishSettingsFileUrl];
}
if (environment.IsEndpointSet(AzureEnvironment.Endpoint.ResourceManager))
{
ResourceManagerUrl =
environment.Endpoints[AzureEnvironment.Endpoint.ResourceManager];
}
if (environment.IsEndpointSet(AzureEnvironment.Endpoint.SqlDatabaseDnsSuffix))
{
SqlDatabaseDnsSuffix =
environment.Endpoints[AzureEnvironment.Endpoint.SqlDatabaseDnsSuffix];
}
if (environment.IsEndpointSet(AzureEnvironment.Endpoint.StorageEndpointSuffix))
{
StorageEndpointSuffix =
environment.Endpoints[AzureEnvironment.Endpoint.StorageEndpointSuffix];
}
if (environment.IsEndpointSet(AzureEnvironment.Endpoint.ActiveDirectory))
{
ActiveDirectoryAuthority =
environment.Endpoints[AzureEnvironment.Endpoint.ActiveDirectory];
}
if (environment.IsEndpointSet(AzureEnvironment.Endpoint.Graph))
{
GraphUrl =
environment.Endpoints[AzureEnvironment.Endpoint.Graph];
}
if (environment.IsEndpointSet(AzureEnvironment.Endpoint.TrafficManagerDnsSuffix))
{
TrafficManagerDnsSuffix =
environment.Endpoints[AzureEnvironment.Endpoint.TrafficManagerDnsSuffix];
}
if (environment.IsEndpointSet(AzureEnvironment.Endpoint.AzureKeyVaultDnsSuffix))
{
AzureKeyVaultDnsSuffix =
environment.Endpoints[AzureEnvironment.Endpoint.AzureKeyVaultDnsSuffix];
}
if (environment.IsEndpointSet(AzureEnvironment.Endpoint.AzureDataLakeStoreFileSystemEndpointSuffix))
{
AzureDataLakeStoreFileSystemEndpointSuffix =
environment.Endpoints[AzureEnvironment.Endpoint.AzureDataLakeStoreFileSystemEndpointSuffix];
}
if (environment.IsEndpointSet(AzureEnvironment.Endpoint.AzureDataLakeAnalyticsCatalogAndJobEndpointSuffix))
{
AzureDataLakeAnalyticsCatalogAndJobEndpointSuffix =
environment.Endpoints[AzureEnvironment.Endpoint.AzureDataLakeAnalyticsCatalogAndJobEndpointSuffix];
}
if (environment.IsEndpointSet(AzureEnvironment.Endpoint.AzureKeyVaultServiceEndpointResourceId))
{
AzureKeyVaultServiceEndpointResourceId =
environment.Endpoints[AzureEnvironment.Endpoint.AzureKeyVaultServiceEndpointResourceId];
}
}
示例3: LoadAccountTenants
private string[] LoadAccountTenants(AzureAccount account, AzureEnvironment environment, SecureString password, ShowDialog promptBehavior)
{
var commonTenantToken = AzureSession.AuthenticationFactory.Authenticate(account, environment,
AuthenticationFactory.CommonAdTenant, password, promptBehavior);
if (environment.IsEndpointSet(AzureEnvironment.Endpoint.ResourceManager))
{
using (CSMSubscriptionClient csmSubscriptionClient = AzureSession.ClientFactory
.CreateCustomClient<CSMSubscriptionClient>(
new TokenCloudCredentials(commonTenantToken.AccessToken),
environment.GetEndpointAsUri(AzureEnvironment.Endpoint.ResourceManager)))
{
return csmSubscriptionClient.Tenants.List().TenantIds.Select(ti => ti.TenantId).ToArray();
}
}
else
{
using (RDFESubscriptionClient rdfeSubscriptionClient = AzureSession.ClientFactory
.CreateCustomClient<RDFESubscriptionClient>(
new TokenCloudCredentials(commonTenantToken.AccessToken),
environment.GetEndpointAsUri(AzureEnvironment.Endpoint.ServiceManagement)))
{
var subscriptionListResult = rdfeSubscriptionClient.Subscriptions.List();
return subscriptionListResult.Subscriptions.Select(s => s.ActiveDirectoryTenantId).Distinct().ToArray();
}
}
}