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

C# Models.AzureContext类代码示例

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

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



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

示例1: GetToken

        private Tuple<IAccessToken, string> GetToken(IAuthenticationFactory authFactory, AzureContext context)
        {
            if (context.Subscription == null)
                throw new ArgumentException(KeyVaultProperties.Resources.InvalidCurrentSubscription);
            if (context.Account == null)
                throw new ArgumentException(KeyVaultProperties.Resources.InvalidSubscriptionState);
            if (context.Account.Type != AzureAccount.AccountType.User)
                throw new ArgumentException(string.Format(KeyVaultProperties.Resources.UnsupportedAccountType, context.Account.Type));
            var tenant = context.Subscription.GetPropertyAsArray(AzureSubscription.Property.Tenants)
                  .Intersect(context.Account.GetPropertyAsArray(AzureAccount.Property.Tenants))
                  .FirstOrDefault();
            if (tenant == null)
                throw new ArgumentException(KeyVaultProperties.Resources.InvalidSubscriptionState);
          
            try
            {
                var accesstoken = authFactory.Authenticate(context.Account, context.Environment, tenant, null, ShowDialog.Auto,
                    ResourceIdEndpoint);

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


示例2: 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:docschmidt,项目名称:azure-powershell,代码行数:41,代码来源:ApiVersionHelper.cs


示例3: 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:fernandoBRS,项目名称:azure-powershell,代码行数:32,代码来源:DataServiceCredential.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:docschmidt,项目名称:azure-powershell,代码行数:12,代码来源:AzureSqlDatabaseAdapter.cs


示例5: 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;
     var 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:kjohn-msft,项目名称:azure-powershell,代码行数:26,代码来源:AzureRMProfileTests.cs


示例6: SqlThreatDetectionAdapter

 public SqlThreatDetectionAdapter(AzureContext context)
 {
     Context = context;
     Subscription = context.Subscription;
     ThreatDetectionCommunicator = new ThreatDetectionEndpointsCommunicator(Context);
     AzureCommunicator = new AzureEndpointsCommunicator(Context);
     AuditingAdapter = new SqlAuditAdapter(context);
 }
开发者ID:injyzarif,项目名称:azure-powershell,代码行数:8,代码来源:SqlThreatDetectionAdapter.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);
     GraphClient = AzureSession.ClientFactory.CreateCustomClient<GraphRbacManagementClient>(
         creds.TenantID,
         creds,
         context.Environment.GetEndpointAsUri(AzureEnvironment.Endpoint.Graph));
 }
开发者ID:docschmidt,项目名称:azure-powershell,代码行数:12,代码来源:ActiveDirectoryClient.cs


示例8: SqlAuditAdapter

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


示例9: 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:dulems,项目名称:azure-powershell,代码行数:12,代码来源:ResourceClient.cs


示例10: Initialize

 /// <summary>
 /// Initialize method
 /// </summary>
 public void Initialize(AzureContext defaultContext, string apiVersion)
 {
     if (!this.Initialized)
     {
         this.IntuneClient = IntuneBaseCmdlet.GetIntuneManagementClient(defaultContext, apiVersion);
         this.Initialized = true;
     }
 }
开发者ID:FrankSiegemund,项目名称:azure-powershell,代码行数:11,代码来源:IntuneResourceManagementClientWrapper.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:docschmidt,项目名称:azure-powershell,代码行数:13,代码来源:AzureSqlDatabaseReplicationAdapter.cs


示例12: AzureSqlCapabilitiesCommunicator

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


示例13: NotificationHubsManagementClient

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

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


示例14: ThreatDetectionEndpointsCommunicator

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


示例15: AzureSqlElasticPoolRecommendationCommunicator

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


示例16: AzureSqlDatabaseTransparentDataEncryptionCommunicator

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


示例17: AzureSqlServerActiveDirectoryAdministratorCommunicator

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


示例18: AzureSqlDatabaseActivationCommunicator

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


示例19: AzureSqlServiceTierAdvisorCommunicator

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


示例20: ApiManagementClient

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

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



注:本文中的Microsoft.Azure.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