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


C# ProfileClient.InitializeProfile方法代码示例

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


在下文中一共展示了ProfileClient.InitializeProfile方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: NewProfileFromCertificateWithNullsThrowsArgumentNullException

 public void NewProfileFromCertificateWithNullsThrowsArgumentNullException()
 {
     MemoryDataStore dataStore = new MemoryDataStore();
     AzureSession.DataStore = dataStore;
     AzureProfile newProfile = new AzureProfile();
     ProfileClient client1 = new ProfileClient(newProfile);
     Assert.Throws<ArgumentNullException>(() =>
         client1.InitializeProfile(null, Guid.NewGuid(), new X509Certificate2(), "foo"));
     Assert.Throws<ArgumentNullException>(() =>
         client1.InitializeProfile(AzureEnvironment.PublicEnvironments["AzureCloud"], Guid.NewGuid(), null, "foo"));
 }
开发者ID:safeermohammed,项目名称:azure-sdk-for-net,代码行数:11,代码来源:ProfileClientTests.cs

示例2: InitializeAzureProfile

        private void InitializeAzureProfile(AzureProfile profile, string parameterSet, AzureProfileSettings settings)
        {
            var savedCache = AzureSession.TokenCache;
            AzureSession.TokenCache = DefaultMemoryTokenCache;
            try
            {

                var profileClient = new ProfileClient(profile);
                if (settings.Environment == null)
                {
                    settings.Environment = AzureEnvironment.PublicEnvironments["AzureCloud"];
                }
                switch (parameterSet)
                {
                    case CertificateParameterSet:
                        profileClient.InitializeProfile(settings.Environment, new Guid(settings.SubscriptionId),
                            settings.Certificate,
                            settings.StorageAccount);
                        break;
                    case CredentialsParameterSet:
                        var userAccount = new AzureAccount
                        {
                            Id = settings.Credential.UserName,
                            Type = AzureAccount.AccountType.User
                        };
                        profileClient.InitializeProfile(settings.Environment, new Guid(settings.SubscriptionId),
                            userAccount,
                            settings.Credential.Password, settings.StorageAccount);
                        break;
                    case AccessTokenParameterSet:
                        profileClient.InitializeProfile(settings.Environment, new Guid(settings.SubscriptionId),
                            settings.AccessToken,
                            settings.AccountId, settings.StorageAccount);
                        break;
                    case ServicePrincipalParameterSet:
                        var servicePrincipalAccount = new AzureAccount
                        {
                            Id = settings.Credential.UserName,
                            Type = AzureAccount.AccountType.ServicePrincipal,
                        };
                        servicePrincipalAccount.SetOrAppendProperty(AzureAccount.Property.Tenants, settings.Tenant);
                        profileClient.InitializeProfile(settings.Environment, new Guid(settings.SubscriptionId),
                            servicePrincipalAccount,
                            settings.Credential.Password, settings.StorageAccount);
                        break;
                    case EmptyParameterSet:
                        if (!profile.Environments.ContainsKey(settings.Environment.Name))
                        {
                            profile.Environments.Add(settings.Environment.Name, settings.Environment);
                        }
                        break;
                }
            }
            finally
            {
                AzureSession.TokenCache = savedCache;
            }
        }
开发者ID:nityasharma,项目名称:azure-powershell,代码行数:58,代码来源:NewAzureProfile.cs

示例3: NewProfileFromCertificateReturnsProfile

        public void NewProfileFromCertificateReturnsProfile()
        {
            MemoryDataStore dataStore = new MemoryDataStore();
            AzureSession.DataStore = dataStore;
            AzureProfile newProfile = new AzureProfile();
            ProfileClient client1 = new ProfileClient(newProfile);
            var subscriptionId = Guid.NewGuid();
            var certificate = new X509Certificate2(Convert.FromBase64String(dummyCertificate));

            client1.InitializeProfile(AzureEnvironment.PublicEnvironments["AzureCloud"],
                subscriptionId, certificate, null);

            Assert.Equal("AzureCloud", newProfile.DefaultSubscription.Environment);
            Assert.Equal(subscriptionId, newProfile.DefaultSubscription.Id);
            Assert.Equal(certificate.Thumbprint, newProfile.DefaultSubscription.Account);
            Assert.False(newProfile.DefaultSubscription.Properties.ContainsKey(AzureSubscription.Property.StorageAccount));
        }
开发者ID:safeermohammed,项目名称:azure-sdk-for-net,代码行数:17,代码来源:ProfileClientTests.cs

示例4: NewProfileFromADWithMismatchSubscriptionThrows

        public void NewProfileFromADWithMismatchSubscriptionThrows()
        {
            SetMocks(new[] { rdfeSubscription1, rdfeSubscription2 }.ToList(), new[] { csmSubscription1 }.ToList());
            MemoryDataStore dataStore = new MemoryDataStore();
            AzureSession.DataStore = dataStore;
            AzureProfile newProfile = new AzureProfile();
            ProfileClient client1 = new ProfileClient(newProfile);
            var newAccount = new AzureAccount { Id = "foo" };
            newAccount.Properties[AzureAccount.Property.Tenants] = "123";

            Assert.Throws<ArgumentException>(() => client1.InitializeProfile(AzureEnvironment.PublicEnvironments["AzureCloud"],
                Guid.NewGuid(), newAccount, null, null));
        }
开发者ID:safeermohammed,项目名称:azure-sdk-for-net,代码行数:13,代码来源:ProfileClientTests.cs

示例5: NewProfileWithAccessTokenReturnsProfile

        public void NewProfileWithAccessTokenReturnsProfile()
        {
            //SetMocks(new[] { rdfeSubscription1, rdfeSubscription2 }.ToList(), new[] { csmSubscription1 }.ToList());
            MemoryDataStore dataStore = new MemoryDataStore();
            AzureSession.DataStore = dataStore;
            AzureProfile newProfile = new AzureProfile();
            ProfileClient client1 = new ProfileClient(newProfile);

            client1.InitializeProfile(AzureEnvironment.PublicEnvironments["AzureCloud"],
                new Guid(csmSubscription1.SubscriptionId), "accessToken", "accountId", null);

            Assert.Equal("AzureCloud", newProfile.DefaultSubscription.Environment);
            Assert.Equal(new Guid(csmSubscription1.SubscriptionId), newProfile.DefaultSubscription.Id);
            Assert.Equal("accountId", newProfile.DefaultSubscription.Account);
            Assert.Equal(AzureAccount.AccountType.AccessToken, newProfile.Context.Account.Type);
            Assert.Equal("accessToken", newProfile.Context.Account.Properties[AzureAccount.Property.AccessToken]);
            Assert.False(newProfile.DefaultSubscription.Properties.ContainsKey(AzureSubscription.Property.StorageAccount));
        }
开发者ID:safeermohammed,项目名称:azure-sdk-for-net,代码行数:18,代码来源:ProfileClientTests.cs

示例6: NewProfileFromADReturnsProfile

        public void NewProfileFromADReturnsProfile()
        {
            SetMocks(new[] { rdfeSubscription1, rdfeSubscription2 }.ToList(), new[] { csmSubscription1 }.ToList());
            MemoryDataStore dataStore = new MemoryDataStore();
            AzureSession.DataStore = dataStore;
            AzureProfile newProfile = new AzureProfile();
            ProfileClient client1 = new ProfileClient(newProfile);
            var newAccount = new AzureAccount {Id = "foo"};
            newAccount.Properties[AzureAccount.Property.Tenants] = "123";

            client1.InitializeProfile(AzureEnvironment.PublicEnvironments["AzureCloud"],
                new Guid(csmSubscription1.SubscriptionId), newAccount, null, null);

            Assert.Equal("AzureCloud", newProfile.DefaultSubscription.Environment);
            Assert.Equal(new Guid(csmSubscription1.SubscriptionId), newProfile.DefaultSubscription.Id);
            Assert.Equal(newAccount.Id, newProfile.DefaultSubscription.Account);
            Assert.False(newProfile.DefaultSubscription.Properties.ContainsKey(AzureSubscription.Property.StorageAccount));
        }
开发者ID:safeermohammed,项目名称:azure-sdk-for-net,代码行数:18,代码来源:ProfileClientTests.cs

示例7: InitializeAzureProfile

 private void InitializeAzureProfile(AzureProfile profile, string parameterSet, AzureProfileSettings settings)
 {
     var profileClient = new ProfileClient(profile);
     if (settings.Environment == null)
     {
         settings.Environment = AzureEnvironment.PublicEnvironments["AzureCloud"];
     }
     switch (parameterSet)
     {
         case CertificateParameterSet:
             profileClient.InitializeProfile(settings.Environment, new Guid(settings.SubscriptionId), settings.Certificate,
                 settings.StorageAccount);
             break;
         case CredentialsParameterSet:
             var userAccount = new AzureAccount
             {
                 Id = settings.Credential.UserName,
                 Type = AzureAccount.AccountType.User
             };
             profileClient.InitializeProfile(settings.Environment, new Guid(settings.SubscriptionId), userAccount,
                 settings.Credential.Password, settings.StorageAccount);
             break;
         case AccessTokenParameterSet:
             profileClient.InitializeProfile(settings.Environment, new Guid(settings.SubscriptionId), settings.AccessToken,
                 settings.AccountId, settings.StorageAccount);
             break;
         case ServicePrincipalParameterSet:
             var servicePrincipalAccount = new AzureAccount
             {
                 Id = settings.Credential.UserName,
                 Type = AzureAccount.AccountType.ServicePrincipal
             };
             profileClient.InitializeProfile(settings.Environment, new Guid(settings.SubscriptionId), servicePrincipalAccount,
                 settings.Credential.Password, settings.StorageAccount);
             break;
     }
 }
开发者ID:shuainie,项目名称:azure-powershell,代码行数:37,代码来源:NewAzureProfile.cs


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