当前位置: 首页>>代码示例>>C#>>正文


C# AzureEnvironment.IsEndpointSet方法代码示例

本文整理汇总了C#中Microsoft.Azure.Commands.Common.Authentication.Models.AzureEnvironment.IsEndpointSet方法的典型用法代码示例。如果您正苦于以下问题:C# AzureEnvironment.IsEndpointSet方法的具体用法?C# AzureEnvironment.IsEndpointSet怎么用?C# AzureEnvironment.IsEndpointSet使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Microsoft.Azure.Commands.Common.Authentication.Models.AzureEnvironment的用法示例。


在下文中一共展示了AzureEnvironment.IsEndpointSet方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
        }
开发者ID:Azure,项目名称:azure-powershell,代码行数:62,代码来源:ProfileClient.cs

示例2: SetEndpoint

 private void SetEndpoint(AzureEnvironment.Endpoint endpoint, AzureEnvironment environment, string endpointValue)
 {
     if (!environment.IsEndpointSet(endpoint) && !string.IsNullOrEmpty(endpointValue))
     {
         environment.Endpoints[endpoint] = endpointValue;
     }
 }
开发者ID:Azure,项目名称:azure-powershell,代码行数:7,代码来源:TypeConversionTests.cs

示例3: CheckEndpoint

 private void CheckEndpoint(AzureEnvironment.Endpoint endpoint, AzureEnvironment environment, string valueToCheck)
 {
     if (environment.IsEndpointSet(endpoint))
     {
         Assert.Equal(environment.GetEndpoint(endpoint), valueToCheck);
     }
 }
开发者ID:Azure,项目名称:azure-powershell,代码行数:7,代码来源:TypeConversionTests.cs

示例4: 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.GraphEndpointResourceId))
     {
         GraphEndpointResourceId =
             environment.Endpoints[AzureEnvironment.Endpoint.GraphEndpointResourceId];
     }
     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];
     }
 }
开发者ID:Azure,项目名称:azure-powershell,代码行数:93,代码来源:PSAzureEnvironment.cs


注:本文中的Microsoft.Azure.Commands.Common.Authentication.Models.AzureEnvironment.IsEndpointSet方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。