• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Models.AzureContext类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



AzureContext类属于Microsoft.Azure.Commands.Common.Authentication.Models命名空间,在下文中一共展示了AzureContext类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: GetToken

        private Tuple<IAccessToken, string> GetToken(IAuthenticationFactory authFactory, AzureContext context, AzureEnvironment.Endpoint resourceIdEndpoint)
        {
            if (context.Account == null)
                throw new ArgumentException(KeyVaultProperties.Resources.ArmAccountNotFound);

            if (context.Account.Type != AzureAccount.AccountType.User &&
                context.Account.Type != AzureAccount.AccountType.ServicePrincipal)
                throw new ArgumentException(string.Format(KeyVaultProperties.Resources.UnsupportedAccountType, context.Account.Type));

            if (context.Subscription != null && context.Account != null)
                TenantId = context.Subscription.GetPropertyAsArray(AzureSubscription.Property.Tenants)
                       .Intersect(context.Account.GetPropertyAsArray(AzureAccount.Property.Tenants))
                       .FirstOrDefault();

            if (string.IsNullOrWhiteSpace(TenantId) && context.Tenant != null && context.Tenant.Id != Guid.Empty)
                TenantId = context.Tenant.Id.ToString();

            if (string.IsNullOrWhiteSpace(TenantId))
                throw new ArgumentException(KeyVaultProperties.Resources.NoTenantInContext);

            try
            {
                var accesstoken = authFactory.Authenticate(context.Account, context.Environment, TenantId, null, ShowDialog.Auto,
                    resourceIdEndpoint);

                return Tuple.Create(accesstoken, context.Environment.Endpoints[resourceIdEndpoint]);
            }
            catch (Exception ex)
            {
                throw new ArgumentException(KeyVaultProperties.Resources.InvalidSubscriptionState, ex);
            }
        }
开发者ID:FrankSiegemund,项目名称:azure-powershell,代码行数:32,代码来源:DataServiceCredential.cs


示例2: ActiveDirectoryClient

        /// <summary>
        /// Creates new ActiveDirectoryClient using WindowsAzureSubscription.
        /// </summary>
        /// <param name="context"></param>
        public ActiveDirectoryClient(AzureContext context)
        {
            GraphClient = AzureSession.ClientFactory.CreateArmClient<GraphRbacManagementClient>(
                context, AzureEnvironment.Endpoint.Graph);

            GraphClient.TenantID = context.Tenant.Id.ToString();
        }
开发者ID:Azure,项目名称:azure-powershell,代码行数:11,代码来源:ActiveDirectoryClient.cs


示例3: SetupTestEnvironment

 private static RMProfileClient SetupTestEnvironment(List<string> tenants, params List<string>[] subscriptionLists)
 {
     AzureSession.AuthenticationFactory = new MockTokenAuthenticationFactory(DefaultAccount,
         Guid.NewGuid().ToString(), DefaultTenant.ToString());
     var subscriptionList = new Queue<List<string>>(subscriptionLists);
     var clientFactory = new MockSubscriptionClientFactory(tenants, subscriptionList);
     var mock = new MockClientFactory(new List<object>
     {
         clientFactory.GetSubscriptionClient()
     }, true);
     mock.MoqClients = true;
     AzureSession.ClientFactory = mock;
     Context = new AzureContext(new AzureSubscription()
         {
             Account = DefaultAccount,
             Environment = EnvironmentName.AzureCloud,
             Id = DefaultSubscription,
             Name = DefaultSubscriptionName
         },
         new AzureAccount() { Id = DefaultAccount, Type = AzureAccount.AccountType.User },
         AzureEnvironment.PublicEnvironments[EnvironmentName.AzureCloud],
         new AzureTenant() { Domain = DefaultDomain, Id = DefaultTenant });
     var profile = new AzureRMProfile();
     profile.Context = Context;
     return new RMProfileClient(profile);
 }
开发者ID:singhkays,项目名称:azure-powershell,代码行数:26,代码来源:AzureRMProfileTests.cs


示例4: AzureSqlDatabaseAdapter

 /// <summary>
 /// Constructs a database adapter
 /// </summary>
 /// <param name="profile">The current azure profile</param>
 /// <param name="subscription">The current azure subscription</param>
 public AzureSqlDatabaseAdapter(AzureContext context)
 {
     Context = context;
     _subscription = context.Subscription;
     Communicator = new AzureSqlDatabaseCommunicator(Context);
     ElasticPoolCommunicator = new AzureSqlElasticPoolCommunicator(Context);
 }
开发者ID:Azure,项目名称:azure-powershell,代码行数:12,代码来源:AzureSqlDatabaseAdapter.cs


示例5: DelegatingHandlersAreCloned

        public void DelegatingHandlersAreCloned()
        {
            string userAccount = "[email protected]";
            Guid subscriptionId = Guid.NewGuid();
             AzureContext context = new AzureContext
            (
                new AzureSubscription()
                {
                    Account = userAccount,
                    Environment = "AzureCloud",
                    Id = subscriptionId,
                    Properties = new Dictionary<AzureSubscription.Property, string>() { { AzureSubscription.Property.Tenants, "common" } }
                }, 
                new AzureAccount()
                {
                    Id = userAccount,
                    Type = AzureAccount.AccountType.User,
                    Properties = new Dictionary<AzureAccount.Property, string>() { { AzureAccount.Property.Tenants, "common" } }
                },
                AzureEnvironment.PublicEnvironments["AzureCloud"]
            );

            AzureSession.AuthenticationFactory = new MockTokenAuthenticationFactory(userAccount, Guid.NewGuid().ToString());
            var mockHandler = new MockDelegatingHandler();
            var factory = new ClientFactory();
            factory.AddHandler(mockHandler);
            var client = factory.CreateClient<StorageManagementClient>(context, AzureEnvironment.Endpoint.ServiceManagement);
            client = factory.CreateClient<StorageManagementClient>(context, AzureEnvironment.Endpoint.ServiceManagement);
            client = factory.CreateClient<StorageManagementClient>(context, AzureEnvironment.Endpoint.ServiceManagement);
            client = factory.CreateClient<StorageManagementClient>(context, AzureEnvironment.Endpoint.ServiceManagement);
            client = factory.CreateClient<StorageManagementClient>(context, AzureEnvironment.Endpoint.ServiceManagement);
            Assert.Equal(5, MockDelegatingHandler.cloneCount); 
        }
开发者ID:Azure,项目名称:azure-powershell,代码行数:33,代码来源:ClientFactoryHandlerTests.cs


示例6: DetermineApiVersion

        /// <summary>
        /// Determines the API version.
        /// </summary>
        /// <param name="context">The azure profile.</param>
        /// <param name="providerNamespace">The provider namespace.</param>
        /// <param name="resourceType">The resource type.</param>
        /// <param name="cancellationToken">The cancellation token</param>
        /// <param name="pre">When specified, indicates if pre-release API versions should be considered.</param>
        internal static Task<string> DetermineApiVersion(AzureContext context, string providerNamespace, string resourceType, CancellationToken cancellationToken, bool? pre = null, Dictionary<string, string> cmdletHeaderValues = null)
        {
            var cacheKey = ApiVersionCache.GetCacheKey(providerNamespace: providerNamespace, resourceType: resourceType);
            var apiVersions = ApiVersionCache.Instance
                .AddOrGetExisting(cacheKey: cacheKey, getFreshData: () => ApiVersionHelper.GetApiVersionsForResourceType(
                    context,
                    providerNamespace: providerNamespace,
                    resourceType: resourceType,
                    cancellationToken: cancellationToken,
                    cmdletHeaderValues: cmdletHeaderValues));

            apiVersions = apiVersions.CoalesceEnumerable().ToArray();
            var apiVersionsToSelectFrom = apiVersions;
            if (pre == null || pre  == false)
            {
                apiVersionsToSelectFrom = apiVersions
                    .Where(apiVersion => apiVersion.IsDecimal(NumberStyles.AllowDecimalPoint) || apiVersion.IsDateTime("yyyy-mm-dd", DateTimeStyles.None))
                    .ToArray();
            }

            var selectedApiVersion = apiVersionsToSelectFrom.OrderByDescending(apiVersion => apiVersion).FirstOrDefault();
            if (string.IsNullOrWhiteSpace(selectedApiVersion) && apiVersions.Any())
            {
                // fall back on pre-release APIs if they're the only ones available.
                selectedApiVersion = apiVersions.OrderByDescending(apiVersion => apiVersion).FirstOrDefault();
            }

            var result = string.IsNullOrWhiteSpace(selectedApiVersion) 
                ? Constants.DefaultApiVersion
                : selectedApiVersion;

            return Task.FromResult(result);
        }
开发者ID:rohmano,项目名称:azure-powershell,代码行数:41,代码来源:ApiVersionHelper.cs


示例7: ActiveDirectoryClient

 /// <summary>
 /// Creates new ActiveDirectoryClient using WindowsAzureSubscription.
 /// </summary>
 /// <param name="context"></param>
 public ActiveDirectoryClient(AzureContext context)
 {
     AccessTokenCredential creds = (AccessTokenCredential)AzureSession.AuthenticationFactory.GetSubscriptionCloudCredentials(context, AzureEnvironment.Endpoint.Graph);
     GraphClient = AzureSession.ClientFactory.CreateCustomClient<GraphRbacManagementClient>(
         creds.TenantID,
         creds,
         context.Environment.GetEndpointAsUri(AzureEnvironment.Endpoint.Graph));
 }
开发者ID:rohmano,项目名称:azure-powershell,代码行数:12,代码来源:ActiveDirectoryClient.cs


示例8: ResourcesClient

        /// <summary>
        /// Creates new ResourceManagementClient
        /// </summary>
        /// <param name="context">Profile containing resources to manipulate</param>
        public ResourcesClient(AzureContext context)
            : this(
                AzureSession.ClientFactory.CreateClient<ResourceManagementClient>(context, AzureEnvironment.Endpoint.ResourceManager),
                new GalleryTemplatesClient(context),
                AzureSession.ClientFactory.CreateClient<AuthorizationManagementClient>(context, AzureEnvironment.Endpoint.ResourceManager))
        {

        }
开发者ID:singhkays,项目名称:azure-powershell,代码行数:12,代码来源:ResourceClient.cs


示例9: SqlThreatDetectionAdapter

 public SqlThreatDetectionAdapter(AzureContext context)
 {
     Context = context;
     Subscription = context.Subscription;
     ThreatDetectionCommunicator = new ThreatDetectionEndpointsCommunicator(Context);
     AzureCommunicator = new AzureEndpointsCommunicator(Context);
     AuditingAdapter = new SqlAuditAdapter(context);
 }
开发者ID:Azure,项目名称:azure-powershell,代码行数:8,代码来源:SqlThreatDetectionAdapter.cs


示例10: SqlAuditAdapter

 public SqlAuditAdapter(AzureContext context)
 {
     Context = context;
     Subscription = context.Subscription;
     Communicator = new AuditingEndpointsCommunicator(Context);
     AzureCommunicator = new AzureEndpointsCommunicator(Context);
     IgnoreStorage = false;
 }
开发者ID:rohmano,项目名称:azure-powershell,代码行数:8,代码来源:SqlAuditAdapter.cs


示例11: AzureSqlDatabaseReplicationAdapter

 /// <summary>
 /// Constructs a database adapter
 /// </summary>
 /// <param name="profile">The current azure profile</param>
 /// <param name="subscription">The current azure subscription</param>
 public AzureSqlDatabaseReplicationAdapter(AzureContext context)
 {
     Context = context;
     _subscription = context.Subscription;
     ReplicationCommunicator = new AzureSqlDatabaseReplicationCommunicator(Context);
     DatabaseCommunicator = new AzureSqlDatabaseCommunicator(Context);
     ServerCommunicator = new AzureSqlServerCommunicator(Context);
 }
开发者ID:Azure,项目名称:azure-powershell,代码行数:13,代码来源:AzureSqlDatabaseReplicationAdapter.cs


示例12: DataMaskingEndpointsCommunicator

 public DataMaskingEndpointsCommunicator(AzureContext context)
 {
     Context = context;
     if (context.Subscription != Subscription)
     {
         Subscription = context.Subscription;
         SqlClient = null;
     }
 }
开发者ID:Azure,项目名称:azure-powershell,代码行数:9,代码来源:DataMaskingEndpointsCommunicator.cs


示例13: AzureSqlDatabaseIndexRecommendationCommunicator

 /// <summary>
 /// Creates a communicator for Azure Sql Databases
 /// </summary>
 /// <param name="profile"></param>
 /// <param name="subscription"></param>
 public AzureSqlDatabaseIndexRecommendationCommunicator(AzureContext context)
 {
     Context = context;
     if (context.Subscription != Subscription)
     {
         Subscription = context.Subscription;
         SqlClient = null;
     }
 }
开发者ID:Azure,项目名称:azure-powershell,代码行数:14,代码来源:AzureSqlDatabaseIndexRecommendationCommunicator.cs


示例14: WebServicesClient

 public WebServicesClient(AzureContext context)
 {
     this.apiClient = AzureSession.ClientFactory.
                                     CreateArmClient<APIClient>(
                                         context,
                                         AzureEnvironment.Endpoint.ResourceManager);
     this.apiClient.LongRunningOperationRetryTimeout =
             WebServicesClient.AsyncOperationPollingIntervalSeconds;
 }
开发者ID:Azure,项目名称:azure-powershell,代码行数:9,代码来源:WebServicesClient.cs


示例15: AzureSqlDatabaseBackupCommunicator

 /// <summary>
 /// Creates a communicator for Azure Sql Database backup REST endpoints.
 /// </summary>
 /// <param name="profile">Azure profile</param>
 /// <param name="subscription">Associated subscription</param>
 public AzureSqlDatabaseBackupCommunicator(AzureContext context)
 {
     Context = context;
     if (context.Subscription != Subscription)
     {
         Subscription = context.Subscription;
         SqlClient = null;
     }
 }
开发者ID:devigned,项目名称:azure-powershell,代码行数:14,代码来源:AzureSqlDatabaseBackupCommunicator.cs


示例16: AzureSqlAdvisorCommunicatorBase

 /// <summary>
 /// Base class contructor for Advisor REST API Communicators.
 /// </summary>
 public AzureSqlAdvisorCommunicatorBase(AzureContext context)
 {
     Context = context;
     if (context.Subscription != Subscription)
     {
         Subscription = context.Subscription;
         SqlClient = null;
     }
 }
开发者ID:Azure,项目名称:azure-powershell,代码行数:12,代码来源:AzureSqlAdvisorCommunicatorBase.cs


示例17: ApiManagementClient

        public ApiManagementClient(AzureContext context)
        {
            if (context == null)
            {
                throw new ArgumentNullException("AzureProfile");
            }

            _context = context;
        }
开发者ID:rohmano,项目名称:azure-powershell,代码行数:9,代码来源:ApiManagementClient.cs


示例18: AzureSqlServerServiceObjectiveCommunicator

 /// <summary>
 /// Creates a communicator for Azure Sql Databases ServiceObjective
 /// </summary>
 /// <param name="profile"></param>
 /// <param name="subscription"></param>
 public AzureSqlServerServiceObjectiveCommunicator(AzureContext context)
 {
     Context = context;
     if (context.Subscription != Subscription)
     {
         Subscription = context.Subscription;
         SqlClient = null;
     }
 }
开发者ID:rohmano,项目名称:azure-powershell,代码行数:14,代码来源:AzureSqlServerServiceObjectiveCommunicator.cs


示例19: AzureSqlElasticPoolCommunicator

 /// <summary>
 /// Creates a communicator for Azure Sql Elastic Pool
 /// </summary>
 /// <param name="profile"></param>
 /// <param name="subscription"></param>
 public AzureSqlElasticPoolCommunicator(AzureContext context)
 {
     Context = context;
     if (context.Subscription != Subscription)
     {
         Subscription = context.Subscription;
         SqlClient = null;
     }
 }
开发者ID:Azure,项目名称:azure-powershell,代码行数:14,代码来源:AzureSqlElasticPoolCommunicator.cs


示例20: NotificationHubsManagementClient

        public NotificationHubsManagementClient(AzureContext azureContext)
        {
            if (azureContext == null)
            {
                throw new ArgumentNullException("azureContext");
            }

            _context = azureContext;
        }
开发者ID:Azure,项目名称:azure-powershell,代码行数:9,代码来源:NotificationHubsManagementClient.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Models.AzureEnvironment类代码示例发布时间:2022-05-26
下一篇:
C# Models.AzureAccount类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap