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


C# Models.AzureSMProfile类代码示例

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


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

示例1: RemovesAzureEnvironment

        public void RemovesAzureEnvironment()
        {
            var commandRuntimeMock = new Mock<ICommandRuntime>();
            commandRuntimeMock.Setup(f => f.ShouldProcess(It.IsAny<string>(), It.IsAny<string>())).Returns(true);

            const string name = "test";
            var profile = new AzureSMProfile(Path.Combine(AzureSession.ProfileDirectory, AzureSession.ProfileFile));
            AzureSMCmdlet.CurrentProfile = profile;
            ProfileClient client = new ProfileClient(profile);
            client.AddOrSetEnvironment(new AzureEnvironment
            {
                Name = name
            });
            client.Profile.Save();

            var cmdlet = new RemoveAzureEnvironmentCommand()
            {
                CommandRuntime = commandRuntimeMock.Object,
                Force = true,
                Name = name
            };

            cmdlet.InvokeBeginProcessing();
            cmdlet.ExecuteCmdlet();
            cmdlet.InvokeEndProcessing();

            client = new ProfileClient(new AzureSMProfile(Path.Combine(AzureSession.ProfileDirectory, AzureSession.ProfileFile)));
            Assert.False(client.Profile.Environments.ContainsKey(name));
        }
开发者ID:Azure,项目名称:azure-powershell,代码行数:29,代码来源:RemoveAzureEnvironmentTests.cs

示例2: DisableAzureWebsiteApplicationDiagnosticApplication

        public void DisableAzureWebsiteApplicationDiagnosticApplication()
        {
            // Setup
            websitesClientMock.Setup(f => f.DisableApplicationDiagnostic(
                websiteName,
                WebsiteDiagnosticOutput.FileSystem, null));

            disableAzureWebsiteApplicationDiagnosticCommand = new DisableAzureWebsiteApplicationDiagnosticCommand()
            {
                CommandRuntime = commandRuntimeMock.Object,
                Name = websiteName,
                WebsitesClient = websitesClientMock.Object,
                File = true,
            };

            currentProfile = new AzureSMProfile();
            var subscription = new AzureSubscription{Id = new Guid(base.subscriptionId) };
            subscription.Properties[AzureSubscription.Property.Default] = "True";
            currentProfile.Subscriptions[new Guid(base.subscriptionId)] = subscription;

            // Test
            disableAzureWebsiteApplicationDiagnosticCommand.ExecuteCmdlet();

            // Assert
            websitesClientMock.Verify(f => f.DisableApplicationDiagnostic(
                websiteName,
                WebsiteDiagnosticOutput.FileSystem, null), Times.Once());

            commandRuntimeMock.Verify(f => f.WriteObject(true), Times.Never());
        }
开发者ID:Azure,项目名称:azure-powershell,代码行数:30,代码来源:DisableAzureWebsiteDiagnosticTests.cs

示例3: GetSubscriptions

        public List<AzureSubscription> GetSubscriptions(AzureSMProfile profile)
        {
            string subscriptions = string.Empty;
            List<AzureSubscription> subscriptionsList = new List<AzureSubscription>();
            if (Properties.ContainsKey(Property.Subscriptions))
            {
                subscriptions = Properties[Property.Subscriptions];
            }

            foreach (var subscription in subscriptions.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries))
            {
                try
                {
                    Guid subscriptionId = new Guid(subscription);
                    Debug.Assert(profile.Subscriptions.ContainsKey(subscriptionId));
                    subscriptionsList.Add(profile.Subscriptions[subscriptionId]);
                }
                catch
                {
                    // Skip
                }
            }

            return subscriptionsList;
        }
开发者ID:Azure,项目名称:azure-powershell,代码行数:25,代码来源:AzureAccount.Methods.cs

示例4: EnvironmentSetupHelper

        public EnvironmentSetupHelper()
        {
            var datastore = new MemoryDataStore();
            AzureSession.DataStore = datastore;
            var profile = new AzureSMProfile(Path.Combine(AzureSession.ProfileDirectory, AzureSession.ProfileFile));
            var rmprofile = new AzureRMProfile(Path.Combine(AzureSession.ProfileDirectory, AzureSession.ProfileFile));
            rmprofile.Environments.Add("foo", AzureEnvironment.PublicEnvironments.Values.FirstOrDefault());
            rmprofile.Context = new AzureContext(new AzureSubscription(), new AzureAccount(), rmprofile.Environments["foo"], new AzureTenant());
            rmprofile.Context.Subscription.Environment = "foo";
            if (AzureRmProfileProvider.Instance.Profile == null)
            {
                AzureRmProfileProvider.Instance.Profile = rmprofile;
            }

            AzureSession.DataStore = datastore;
            ProfileClient = new ProfileClient(profile);

            // Ignore SSL errors
            System.Net.ServicePointManager.ServerCertificateValidationCallback += (se, cert, chain, sslerror) => true;

            AdalTokenCache.ClearCookies();

            // Set RunningMocked
            TestMockSupport.RunningMocked = HttpMockServer.GetCurrentMode() == HttpRecorderMode.Playback;
        }
开发者ID:Azure,项目名称:azure-powershell,代码行数:25,代码来源:EnvironmentSetupHelper.cs

示例5: CreateAzureSMProfile

 public static AzureSMProfile CreateAzureSMProfile(string storageAccount)
 {
     var profile = new AzureSMProfile();
     var client = new ProfileClient(profile);
     var tenantId = Guid.NewGuid();
     var subscriptionId = Guid.NewGuid();
     var account = new AzureAccount
     {
         Id = "[email protected]",
         Type = AzureAccount.AccountType.User
     };
     account.SetProperty(AzureAccount.Property.Tenants, tenantId.ToString());
     account.SetProperty(AzureAccount.Property.Subscriptions, subscriptionId.ToString());
     var subscription = new AzureSubscription()
     {
         Id = subscriptionId,
         Name = "Test Subscription 1",
         Environment = EnvironmentName.AzureCloud,
         Account = account.Id,
     };
     subscription.SetProperty(AzureSubscription.Property.Tenants, tenantId.ToString());
     subscription.SetProperty(AzureSubscription.Property.StorageAccount, storageAccount);
     client.AddOrSetAccount(account);
     client.AddOrSetSubscription(subscription);
     client.SetSubscriptionAsDefault(subscriptionId, account.Id);
     return profile;
 }
开发者ID:rohmano,项目名称:azure-powershell,代码行数:27,代码来源:CommonDataCmdletTests.cs

示例6: BaseSetup

        public void BaseSetup()
        {
            if (AzureSession.DataStore != null && !(AzureSession.DataStore is MemoryDataStore))
            {
                AzureSession.DataStore = new MemoryDataStore();
            }
            currentProfile = new AzureSMProfile();

            if (currentProfile.Context.Subscription == null)
            {
                var newGuid = Guid.NewGuid();
                var client = new ProfileClient(currentProfile);
                client.AddOrSetAccount(new AzureAccount
                    {
                        Id = "test",
                        Type = AzureAccount.AccountType.User,
                        Properties = new Dictionary<AzureAccount.Property, string>
                        {
                            {AzureAccount.Property.Subscriptions, newGuid.ToString()}
                        }
                    });
               client.AddOrSetSubscription( new AzureSubscription { Id = newGuid, Name = "test", Environment = EnvironmentName.AzureCloud, Account = "test" });
               client.SetSubscriptionAsDefault(newGuid, "test");
           }
            AzureSession.AuthenticationFactory = new MockTokenAuthenticationFactory();
        }
开发者ID:rohmano,项目名称:azure-powershell,代码行数:26,代码来源:SMTestBase.cs

示例7: WebsitesClient

 /// <summary>
 /// Creates new WebsitesClient
 /// </summary>
 /// <param name="subscription">Subscription containing websites to manipulate</param>
 /// <param name="logger">The logger action</param>
 public WebsitesClient(AzureSMProfile profile, AzureSubscription subscription, Action<string> logger)
 {
     Logger = logger;
     cloudServiceClient = new CloudServiceClient(profile, subscription, debugStream: logger);
     WebsiteManagementClient = AzureSession.ClientFactory.CreateClient<WebSiteManagementClient>(profile, subscription, AzureEnvironment.Endpoint.ServiceManagement);
     this.subscription = subscription;
 }
开发者ID:rohmano,项目名称:azure-powershell,代码行数:12,代码来源:WebsitesClient.cs

示例8: SwitchesSlots

        public void SwitchesSlots()
        {
            // Setup
            var mockClient = new Mock<IWebsitesClient>();
            string slot1 = WebsiteSlotName.Production.ToString();
            string slot2 = "staging";

            mockClient.Setup(c => c.GetWebsiteSlots("website1"))
                .Returns(new List<Site> { 
                    new Site { Name = "website1", WebSpace = "webspace1" },
                    new Site { Name = "website1(staging)", WebSpace = "webspace1" }
                });
            mockClient.Setup(f => f.GetSlotName("website1")).Returns(slot1);
            mockClient.Setup(f => f.GetSlotName("website1(staging)")).Returns(slot2);
            mockClient.Setup(f => f.SwitchSlots("webspace1", "website1(staging)", slot1, slot2)).Verifiable();
            mockClient.Setup(f => f.GetWebsiteNameFromFullName("website1")).Returns("website1");

            // Test
            SwitchAzureWebsiteSlotCommand switchAzureWebsiteCommand = new SwitchAzureWebsiteSlotCommand
            {
                CommandRuntime = new MockCommandRuntime(),
                WebsitesClient = mockClient.Object,
                Name = "website1",
                Force = true
            };
            currentProfile = new AzureSMProfile();
            var subscription = new AzureSubscription { Id = new Guid(base.subscriptionId) };
            subscription.Properties[AzureSubscription.Property.Default] = "True";
            currentProfile.Subscriptions[new Guid(base.subscriptionId)] = subscription;

            // Switch existing website
            switchAzureWebsiteCommand.ExecuteCmdlet();
            mockClient.Verify(c => c.SwitchSlots("webspace1", "website1", slot1, slot2), Times.Once());
        }
开发者ID:Azure,项目名称:azure-powershell,代码行数:34,代码来源:SwitchAzureWebSiteSlotTests.cs

示例9: ListWebHostingPlansTest

        public void ListWebHostingPlansTest()
        {
            // Setup
            var clientMock = new Mock<IWebsitesClient>();
            clientMock.Setup(c => c.ListWebSpaces())
                .Returns(new[] {new WebSpace {Name = "webspace1"}, new WebSpace {Name = "webspace2"}});

            clientMock.Setup(c => c.ListWebHostingPlans())
                .Returns(new List<WebHostingPlan>
                {
                    new WebHostingPlan {Name = "Plan1", WebSpace = "webspace1"},
                    new WebHostingPlan { Name = "Plan2", WebSpace = "webspace2" }
                });
             
            // Test
            var command = new GetAzureWebHostingPlanCommand
            {
                CommandRuntime = new MockCommandRuntime(),
                WebsitesClient = clientMock.Object
            };
            currentProfile = new AzureSMProfile();
            var subscription = new AzureSubscription{Id = new Guid(subscriptionId) };
            subscription.Properties[AzureSubscription.Property.Default] = "True";
            currentProfile.Subscriptions[new Guid(subscriptionId)] = subscription;

            command.ExecuteCmdlet();

            var plans = System.Management.Automation.LanguagePrimitives.GetEnumerable(((MockCommandRuntime)command.CommandRuntime).OutputPipeline).Cast<WebHostingPlan>();

            Assert.NotNull(plans);
            Assert.Equal(2, plans.Count());
            Assert.True(plans.Any(p => (p).Name.Equals("Plan1") && (p).WebSpace.Equals("webspace1")));
            Assert.True(plans.Any(p => (p).Name.Equals("Plan2") && (p).WebSpace.Equals("webspace2")));
        }
开发者ID:Azure,项目名称:azure-powershell,代码行数:34,代码来源:GetAzureWebHostingPlanTests.cs

示例10: ProcessShowWebsiteTest

        public void ProcessShowWebsiteTest()
        {
            // Setup
            var mockClient = new Mock<IWebsitesClient>();
            mockClient.Setup(c => c.GetWebsite("website1", null))
                .Returns(new Site
                {
                    Name = "website1",
                    WebSpace = "webspace1",
                    HostNames = new[] {"website1.cloudapp.com"}
                });

            // Test
            ShowAzureWebsiteCommand showAzureWebsiteCommand = new ShowAzureWebsiteCommand
            {
                CommandRuntime = new MockCommandRuntime(),
                Name = "website1",
                WebsitesClient = mockClient.Object
            };
            currentProfile = new AzureSMProfile();
            var subscription = new AzureSubscription{Id = new Guid(base.subscriptionId) };
            subscription.Properties[AzureSubscription.Property.Default] = "True";
            currentProfile.Subscriptions[new Guid(base.subscriptionId)] = subscription;

            // Show existing website
            showAzureWebsiteCommand.ExecuteCmdlet();
        }
开发者ID:Azure,项目名称:azure-powershell,代码行数:27,代码来源:ShowAzureWebsiteTests.cs

示例11: StopsWebsiteSlot

        public void StopsWebsiteSlot()
        {
            const string slot = "staging";
            const string websiteName = "website1";

            // Setup
            Mock<IWebsitesClient> websitesClientMock = new Mock<IWebsitesClient>();
            websitesClientMock.Setup(f => f.StopWebsite(websiteName, slot));

            // Test
            StopAzureWebsiteCommand stopAzureWebsiteCommand = new StopAzureWebsiteCommand()
            {
                CommandRuntime = new MockCommandRuntime(),
                Name = websiteName,
                WebsitesClient = websitesClientMock.Object,
                Slot = slot
            };
            currentProfile = new AzureSMProfile();
            var subscription = new AzureSubscription{Id = new Guid(base.subscriptionId) };
            subscription.Properties[AzureSubscription.Property.Default] = "True";
            currentProfile.Subscriptions[new Guid(base.subscriptionId)] = subscription;

            stopAzureWebsiteCommand.ExecuteCmdlet();

            websitesClientMock.Verify(f => f.StopWebsite(websiteName, slot), Times.Once());
        }
开发者ID:Azure,项目名称:azure-powershell,代码行数:26,代码来源:StopAzureWebSiteTests.cs

示例12: ClearAzureProfileClearsDefaultProfile

        public void ClearAzureProfileClearsDefaultProfile()
        {
            ClearAzureProfileCommand cmdlt = new ClearAzureProfileCommand();
            // Setup
            var profile = new AzureSMProfile(Path.Combine(AzureSession.ProfileDirectory, AzureSession.ProfileFile));
            AzureSMCmdlet.CurrentProfile = profile;
            ProfileClient client = new ProfileClient(profile);
            client.AddOrSetAccount(azureAccount);
            client.AddOrSetEnvironment(azureEnvironment);
            client.AddOrSetSubscription(azureSubscription1);
            client.Profile.Save();

            cmdlt.CommandRuntime = commandRuntimeMock;
            cmdlt.Force = new SwitchParameter(true);

            // Act
            cmdlt.InvokeBeginProcessing();
            cmdlt.ExecuteCmdlet();
            cmdlt.InvokeEndProcessing();

            // Verify
            client = new ProfileClient(new AzureSMProfile(Path.Combine(AzureSession.ProfileDirectory, AzureSession.ProfileFile)));
            Assert.Equal(0, client.Profile.Subscriptions.Count);
            Assert.Equal(0, client.Profile.Accounts.Count);
            Assert.Equal(4, client.Profile.Environments.Count); //only default environments
        }
开发者ID:Azure,项目名称:azure-powershell,代码行数:26,代码来源:ProfileCmdltsTests.cs

示例13: Serialize

 public string Serialize(AzureSMProfile profile)
 {
     return JsonConvert.SerializeObject(new
     {
         Environments = profile.Environments.Values.ToList(),
         Subscriptions = profile.Subscriptions.Values.ToList(),
         Accounts = profile.Accounts.Values.ToList()
     }, Formatting.Indented);
 }
开发者ID:rohmano,项目名称:azure-powershell,代码行数:9,代码来源:JsonProfileSerializer.cs

示例14: ServerDataServiceCertAuth

 /// <summary>
 /// Initializes a new instance of the <see cref="ServerDataServiceCertAuth"/> class
 /// </summary>
 /// <param name="subscription">The subscription used to connect and authenticate.</param>
 /// <param name="serverName">The name of the server to connect to.</param>
 private ServerDataServiceCertAuth(
     AzureSMProfile profile,
     AzureSubscription subscription,
     string serverName)
 {
     this.profile = profile;
     this.serverName = serverName;
     this.subscription = subscription;
 }
开发者ID:Azure,项目名称:azure-powershell,代码行数:14,代码来源:ServerDataServiceCertAuth.cs

示例15: ProfileMigratesOldData

        public void ProfileMigratesOldData()
        {
            MemoryDataStore dataStore = new MemoryDataStore();
            dataStore.VirtualStore[oldProfileDataPath] = oldProfileData;
            AzureSession.DataStore = dataStore;
            currentProfile = new AzureSMProfile(Path.Combine(AzureSession.ProfileDirectory, AzureSession.ProfileFile));
            ProfileClient client = new ProfileClient(currentProfile);

            Assert.False(dataStore.FileExists(oldProfileDataPath));
            Assert.True(dataStore.FileExists(newProfileDataPath));
        }
开发者ID:Azure,项目名称:azure-powershell,代码行数:11,代码来源:ProfileClientTests.cs


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