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


C# AzureSMProfile.Save方法代码示例

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


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

示例1: SetupProfile

        protected void SetupProfile(string storageName)
        {

            currentProfile = new AzureSMProfile(Path.Combine(AzureSession.ProfileDirectory, AzureSession.ProfileFile));
            AzureSMCmdlet.CurrentProfile = currentProfile;
            var subscription = new AzureSubscription { Id = new Guid(subscriptionId) };
            subscription.Properties[AzureSubscription.Property.Default] = "True";
            currentProfile.Subscriptions[new Guid(subscriptionId)] = subscription;
            if (storageName != null)
            {
                currentProfile.Context.Subscription.Properties[AzureSubscription.Property.StorageAccount] = storageName;
            }
            currentProfile.Save();
        }
开发者ID:docschmidt,项目名称:azure-powershell,代码行数:14,代码来源:WebsitesTestBase.cs

示例2: UpgradeProfile

        private void UpgradeProfile()
        {
            string oldProfileFilePath = Path.Combine(AzureSession.ProfileDirectory, AzureSession.OldProfileFile);
            string oldProfileFilePathBackup = Path.Combine(AzureSession.ProfileDirectory, AzureSession.OldProfileFileBackup);
            string newProfileFilePath = Path.Combine(AzureSession.ProfileDirectory, AzureSession.ProfileFile);
            if (AzureSession.DataStore.FileExists(oldProfileFilePath))
            {
                string oldProfilePath = Path.Combine(AzureSession.ProfileDirectory,
                    AzureSession.OldProfileFile);

                try
                {
                    // Try to backup old profile
                    try
                    {
                        AzureSession.DataStore.CopyFile(oldProfilePath, oldProfileFilePathBackup);
                    }
                    catch
                    {
                        // Ignore any errors here
                    }

                    AzureSMProfile oldProfile = new AzureSMProfile(oldProfilePath);

                    if (AzureSession.DataStore.FileExists(newProfileFilePath))
                    {
                        // Merge profile files
                        AzureSMProfile newProfile = new AzureSMProfile(newProfileFilePath);
                        foreach (var environment in newProfile.Environments.Values)
                        {
                            oldProfile.Environments[environment.Name] = environment;
                        }
                        foreach (var subscription in newProfile.Subscriptions.Values)
                        {
                            oldProfile.Subscriptions[subscription.Id] = subscription;
                        }
                        AzureSession.DataStore.DeleteFile(newProfileFilePath);
                    }

                    // If there were no load errors - delete backup file
                    if (oldProfile.ProfileLoadErrors.Count == 0)
                    {
                        try
                        {
                            AzureSession.DataStore.DeleteFile(oldProfileFilePathBackup);
                        }
                        catch
                        {
                            // Give up
                        }
                    }

                    // Save the profile to the disk
                    oldProfile.Save();

                    // Rename WindowsAzureProfile.xml to WindowsAzureProfile.json
                    AzureSession.DataStore.RenameFile(oldProfilePath, newProfileFilePath);

                }
                catch
                {
                    // Something really bad happened - try to delete the old profile
                    try
                    {
                        AzureSession.DataStore.DeleteFile(oldProfilePath);
                    }
                    catch
                    {
                        // Ignore any errors
                    }
                }

                // In case that we changed a disk profile, reload it
                if (Profile != null && Profile.ProfilePath == newProfileFilePath)
                {
                    Profile = new AzureSMProfile(Profile.ProfilePath);
                }
            }
        }
开发者ID:rbramwell,项目名称:azure-powershell,代码行数:79,代码来源:ProfileClient.cs

示例3: SetupCustomProfile

 private AzureSMProfile SetupCustomProfile(string path)
 {
     var profile =
         new AzureSMProfile(path);
     ProfileClient client = new ProfileClient(profile);
     client.AddOrSetEnvironment(azureEnvironment);
     client.AddOrSetAccount(azureAccount);
     client.AddOrSetSubscription(azureSubscription1);
     client.AddOrSetSubscription(azureSubscription2);
     profile.Save(path);
     return profile;
 }
开发者ID:rbramwell,项目名称:azure-powershell,代码行数:12,代码来源:ProfileCmdltsTests.cs

示例4: ProcessGetWebsiteWithNullSubscription

        public void ProcessGetWebsiteWithNullSubscription()
        {
            currentProfile = new AzureSMProfile(Path.Combine(AzureSession.ProfileDirectory, AzureSession.ProfileFile));
            currentProfile.Subscriptions.Clear();
            currentProfile.Save();
            AzureSMCmdlet.CurrentProfile = currentProfile;

            // Test
            var getAzureWebsiteCommand = new GetAzureWebsiteCommand
            {
                CommandRuntime = new MockCommandRuntime()
            };

            Testing.AssertThrows<Exception>(getAzureWebsiteCommand.ExecuteWithProcessing, Resources.InvalidDefaultSubscription);
        }
开发者ID:docschmidt,项目名称:azure-powershell,代码行数:15,代码来源:GetAzureWebSiteTests.cs


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