diff options
| author | Roy Ben Shabat <Roy.mail.net@gmail.com> | 2020-02-06 23:01:31 +0200 |
|---|---|---|
| committer | Roy Ben Shabat <Roy.mail.net@gmail.com> | 2020-02-06 23:01:31 +0200 |
| commit | d6223286f10478ba2607852a287fa39151e0fcaf (patch) | |
| tree | 272bfd2f7e8a3600136e1a524b5b54a075b3bedd /Software/Visual_Studio/Azure | |
| parent | 81ae2d2ffc13e85d9cc47a76e3c1002ed3ce1c06 (diff) | |
| download | Tango-d6223286f10478ba2607852a287fa39151e0fcaf.tar.gz Tango-d6223286f10478ba2607852a287fa39151e0fcaf.zip | |
Working on azure utils...
Diffstat (limited to 'Software/Visual_Studio/Azure')
10 files changed, 283 insertions, 44 deletions
diff --git a/Software/Visual_Studio/Azure/Tango.AzureUtils.UI/Controls/WebAppPropertiesControl.xaml b/Software/Visual_Studio/Azure/Tango.AzureUtils.UI/Controls/WebAppPropertiesControl.xaml new file mode 100644 index 000000000..54293c7d8 --- /dev/null +++ b/Software/Visual_Studio/Azure/Tango.AzureUtils.UI/Controls/WebAppPropertiesControl.xaml @@ -0,0 +1,58 @@ +<UserControl x:Class="Tango.AzureUtils.UI.Controls.WebAppPropertiesControl" + xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" + xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" + xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" + xmlns:d="http://schemas.microsoft.com/expression/blend/2008" + xmlns:controls="clr-namespace:Tango.SharedUI.Controls;assembly=Tango.SharedUI" + xmlns:azure="clr-namespace:Microsoft.Azure.Management.AppService.Fluent;assembly=Microsoft.Azure.Management.AppService.Fluent" + xmlns:local="clr-namespace:Tango.AzureUtils.UI.Controls" + mc:Ignorable="d" + d:DesignHeight="450" d:DesignWidth="800" d:DataContext="{d:DesignInstance Type=azure:IWebAppBase, IsDesignTimeCreatable=False}" x:Name="control" > + <Grid> + <StackPanel TextElement.FontSize="10"> + <controls:TableGrid RowHeight="30"> + <TextBlock FontWeight="SemiBold">ADDRESS:</TextBlock> + <ItemsControl ItemsSource="{Binding ElementName=control,Path=HostNames}"/> + + <TextBlock FontWeight="SemiBold">REGION:</TextBlock> + <TextBlock Text="{Binding RegionName}"></TextBlock> + + <TextBlock FontWeight="SemiBold">HTTPS ONLY:</TextBlock> + <TextBlock Text="{Binding HttpsOnly}"></TextBlock> + + <TextBlock FontWeight="SemiBold">REMOTE DEBUGGING:</TextBlock> + <TextBlock Text="{Binding Converter={StaticResource IWebAppPropertyToStringConverter},ConverterParameter='RemoteDebuggingEnabled'}"></TextBlock> + + <TextBlock FontWeight="SemiBold">STATE:</TextBlock> + <TextBlock Text="{Binding Converter={StaticResource IWebAppPropertyToStringConverter},ConverterParameter='State'}"></TextBlock> + + <TextBlock FontWeight="SemiBold">DB_ADDRESS:</TextBlock> + <TextBlock Text="{Binding ElementName=control,Path=Settings.DB_ADDRESS}"></TextBlock> + + <TextBlock FontWeight="SemiBold">DB_CATALOG:</TextBlock> + <TextBlock Text="{Binding ElementName=control,Path=Settings.DB_CATALOG}"></TextBlock> + + <TextBlock FontWeight="SemiBold">DB_USER_NAME:</TextBlock> + <TextBlock Text="{Binding ElementName=control,Path=Settings.DB_USER_NAME}"></TextBlock> + + <TextBlock FontWeight="SemiBold">DEPLOYMENT_SLOT:</TextBlock> + <TextBlock Text="{Binding ElementName=control,Path=Settings.DEPLOYMENT_SLOT}"></TextBlock> + + <TextBlock FontWeight="SemiBold">ENFORCE_MACHINE_STUDIO_VERSION:</TextBlock> + <TextBlock Text="{Binding ElementName=control,Path=Settings.ENFORCE_MACHINE_STUDIO_VERSION}"></TextBlock> + + <TextBlock FontWeight="SemiBold">ENVIRONMENT_GROUP:</TextBlock> + <TextBlock Text="{Binding ElementName=control,Path=Settings.ENVIRONMENT_GROUP}"></TextBlock> + + <TextBlock FontWeight="SemiBold">MACHINE_STUDIO_VERSIONS_CONTAINER:</TextBlock> + <TextBlock Text="{Binding ElementName=control,Path=Settings.MACHINE_STUDIO_VERSIONS_CONTAINER}"></TextBlock> + + <TextBlock FontWeight="SemiBold">STORAGE_ACCOUNT:</TextBlock> + <TextBlock Text="{Binding ElementName=control,Path=Settings.STORAGE_ACCOUNT}"></TextBlock> + + <TextBlock FontWeight="SemiBold">TANGO_VERSIONS_CONTAINER:</TextBlock> + <TextBlock Text="{Binding ElementName=control,Path=Settings.TANGO_VERSIONS_CONTAINER}"></TextBlock> + </controls:TableGrid> + </StackPanel> + </Grid> +</UserControl> diff --git a/Software/Visual_Studio/Azure/Tango.AzureUtils.UI/Controls/WebAppPropertiesControl.xaml.cs b/Software/Visual_Studio/Azure/Tango.AzureUtils.UI/Controls/WebAppPropertiesControl.xaml.cs new file mode 100644 index 000000000..f046546f7 --- /dev/null +++ b/Software/Visual_Studio/Azure/Tango.AzureUtils.UI/Controls/WebAppPropertiesControl.xaml.cs @@ -0,0 +1,64 @@ +using Microsoft.Azure.Management.AppService.Fluent; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace Tango.AzureUtils.UI.Controls +{ + /// <summary> + /// Interaction logic for WebAppPropertiesControl.xaml + /// </summary> + public partial class WebAppPropertiesControl : UserControl + { + public MachineServiceSettings Settings + { + get { return (MachineServiceSettings)GetValue(SettingsProperty); } + set { SetValue(SettingsProperty, value); } + } + public static readonly DependencyProperty SettingsProperty = + DependencyProperty.Register("Settings", typeof(MachineServiceSettings), typeof(WebAppPropertiesControl), new PropertyMetadata(null)); + + public List<String> HostNames + { + get { return (List<String>)GetValue(HostNamesProperty); } + set { SetValue(HostNamesProperty, value); } + } + public static readonly DependencyProperty HostNamesProperty = + DependencyProperty.Register("HostNames", typeof(List<String>), typeof(WebAppPropertiesControl), new PropertyMetadata(null)); + + + public WebAppPropertiesControl() + { + InitializeComponent(); + + DataContextChanged += WebAppPropertiesControl_DataContextChanged; + } + + private async void WebAppPropertiesControl_DataContextChanged(object sender, DependencyPropertyChangedEventArgs e) + { + if (DataContext != null && DataContext is IWebAppBase) + { + IWebAppBase app = DataContext as IWebAppBase; + + try + { + HostNames = app.HostNames.Select(x => x).ToList(); + + Settings = await app.GetMachineServiceSettingsAsync(false); + } + catch { } + } + } + } +} diff --git a/Software/Visual_Studio/Azure/Tango.AzureUtils.UI/Converters/IWebAppPropertyToStringConverter.cs b/Software/Visual_Studio/Azure/Tango.AzureUtils.UI/Converters/IWebAppPropertyToStringConverter.cs new file mode 100644 index 000000000..e2fa1bdb4 --- /dev/null +++ b/Software/Visual_Studio/Azure/Tango.AzureUtils.UI/Converters/IWebAppPropertyToStringConverter.cs @@ -0,0 +1,54 @@ +using Microsoft.Azure.Management.AppService.Fluent; +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Linq; +using System.Reflection; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Data; + +namespace Tango.AzureUtils.UI.Converters +{ + public class IWebAppPropertyToStringConverter : IValueConverter + { + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + IWebAppBase app = value as IWebAppBase; + + if (app != null) + { + String propName = parameter.ToStringSafe(); + Object propValue = null; + + try + { + propValue = typeof(IWebAppBase).GetProperty(propName).GetValue(app); + return propValue; + } + catch + { + try + { + propValue = typeof(IWebAppBase).GetField(propName).GetValue(app); + return propValue; + } + catch + { + return null; + } + } + } + else + { + return null; + } + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + throw new NotImplementedException(); + } + } +} diff --git a/Software/Visual_Studio/Azure/Tango.AzureUtils.UI/Resources/Converters.xaml b/Software/Visual_Studio/Azure/Tango.AzureUtils.UI/Resources/Converters.xaml index 36c68c859..a1e0c3fdc 100644 --- a/Software/Visual_Studio/Azure/Tango.AzureUtils.UI/Resources/Converters.xaml +++ b/Software/Visual_Studio/Azure/Tango.AzureUtils.UI/Resources/Converters.xaml @@ -5,6 +5,7 @@ xmlns:local="clr-namespace:Tango.AzureUtils.UI.Resources"> <localConverters:IWebAppBaseToDisplayNameConverter x:Key="IWebAppBaseToDisplayNameConverter" /> + <localConverters:IWebAppPropertyToStringConverter x:Key="IWebAppPropertyToStringConverter" /> <converters:BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" /> <converters:BooleanInverseConverter x:Key="BooleanInverseConverter" /> diff --git a/Software/Visual_Studio/Azure/Tango.AzureUtils.UI/Tango.AzureUtils.UI.csproj b/Software/Visual_Studio/Azure/Tango.AzureUtils.UI/Tango.AzureUtils.UI.csproj index 4f67722f4..6812a5695 100644 --- a/Software/Visual_Studio/Azure/Tango.AzureUtils.UI/Tango.AzureUtils.UI.csproj +++ b/Software/Visual_Studio/Azure/Tango.AzureUtils.UI/Tango.AzureUtils.UI.csproj @@ -194,7 +194,11 @@ <SubType>Designer</SubType> </ApplicationDefinition> <Compile Include="AzureDashboardViewModel.cs" /> + <Compile Include="Controls\WebAppPropertiesControl.xaml.cs"> + <DependentUpon>WebAppPropertiesControl.xaml</DependentUpon> + </Compile> <Compile Include="Converters\IWebAppBaseToDisplayNameConverter.cs" /> + <Compile Include="Converters\IWebAppPropertyToStringConverter.cs" /> <Compile Include="Managers\DefaultStatusManager.cs" /> <Compile Include="Managers\IStatusManager.cs" /> <Compile Include="ViewModelLocator.cs" /> @@ -210,6 +214,10 @@ <Compile Include="Views\MainView.xaml.cs"> <DependentUpon>MainView.xaml</DependentUpon> </Compile> + <Page Include="Controls\WebAppPropertiesControl.xaml"> + <SubType>Designer</SubType> + <Generator>MSBuild:Compile</Generator> + </Page> <Page Include="MainWindow.xaml"> <Generator>MSBuild:Compile</Generator> <SubType>Designer</SubType> diff --git a/Software/Visual_Studio/Azure/Tango.AzureUtils.UI/ViewModels/EnvironmentCreationViewVM.cs b/Software/Visual_Studio/Azure/Tango.AzureUtils.UI/ViewModels/EnvironmentCreationViewVM.cs index fe585191d..d51cfb3bd 100644 --- a/Software/Visual_Studio/Azure/Tango.AzureUtils.UI/ViewModels/EnvironmentCreationViewVM.cs +++ b/Software/Visual_Studio/Azure/Tango.AzureUtils.UI/ViewModels/EnvironmentCreationViewVM.cs @@ -58,11 +58,19 @@ namespace Tango.AzureUtils.UI.ViewModels set { _password = value; RaisePropertyChangedAuto(); } } - public RelayCommand CreateDeploymentSlotCommand { get; set; } + private CreateEnvironmentConfiguration _config; + public CreateEnvironmentConfiguration Config + { + get { return _config; } + set { _config = value; RaisePropertyChangedAuto(); } + } + + public RelayCommand CreateEnvironmentCommand { get; set; } public EnvironmentCreationViewVM() { - CreateDeploymentSlotCommand = new RelayCommand(CreateDeploymentSlot); + CreateEnvironmentCommand = new RelayCommand(CreateEnvironment); + Config = new CreateEnvironmentConfiguration(); } public override void OnApplicationReady() @@ -95,18 +103,18 @@ namespace Tango.AzureUtils.UI.ViewModels } } - private async void CreateDeploymentSlot() + private async void CreateEnvironment() { try { if (!Validate()) return; IsFree = false; - await _environmentManager.CreateEnvironment(_machineServiceApp as IWebApp, SelectedDeploymentSlot, SlotName, new CreateEnvironmentConfiguration() - { - Email = Email, - Password = Password - }); + + Config.Email = Email; + Config.Password = Password; + + await _environmentManager.CreateEnvironment(_machineServiceApp as IWebApp, SelectedDeploymentSlot, SlotName, Config); } catch (Exception ex) { diff --git a/Software/Visual_Studio/Azure/Tango.AzureUtils.UI/Views/EnvironmentCreationView.xaml b/Software/Visual_Studio/Azure/Tango.AzureUtils.UI/Views/EnvironmentCreationView.xaml index c7278e2da..d417d6c93 100644 --- a/Software/Visual_Studio/Azure/Tango.AzureUtils.UI/Views/EnvironmentCreationView.xaml +++ b/Software/Visual_Studio/Azure/Tango.AzureUtils.UI/Views/EnvironmentCreationView.xaml @@ -7,6 +7,7 @@ xmlns:helpers="clr-namespace:Tango.SharedUI.Helpers;assembly=Tango.SharedUI" xmlns:global="clr-namespace:Tango.AzureUtils.UI" xmlns:local="clr-namespace:Tango.AzureUtils.UI.Views" + xmlns:localControls="clr-namespace:Tango.AzureUtils.UI.Controls" mc:Ignorable="d" d:DesignHeight="700" d:DesignWidth="1100" @@ -16,29 +17,54 @@ Foreground="{StaticResource PrimaryForegroundBrush}"> <Grid> <Grid.ColumnDefinitions> - <ColumnDefinition Width="300"/> - <ColumnDefinition Width="1*"/> + <ColumnDefinition Width="50*"/> + <ColumnDefinition Width="60*"/> </Grid.ColumnDefinitions> - <GroupBox Header="Source Deployment Slot" Padding="5"> - <StackPanel> - <ComboBox ItemsSource="{Binding DeploymentSlots}" SelectedItem="{Binding SelectedDeploymentSlot}" DisplayMemberPath="Name"></ComboBox> - </StackPanel> + <GroupBox Header="Source Deployment Slot" Padding="5" Margin="10"> + <DockPanel> + <ComboBox DockPanel.Dock="Top" ItemsSource="{Binding DeploymentSlots}" SelectedItem="{Binding SelectedDeploymentSlot}" DisplayMemberPath="Name"></ComboBox> + + <localControls:WebAppPropertiesControl VerticalAlignment="Top" Margin="0 20 0 0" DataContext="{Binding SelectedDeploymentSlot}" /> + </DockPanel> </GroupBox> <Grid Grid.Column="1"> - <StackPanel HorizontalAlignment="Center" VerticalAlignment="Center" MinWidth="300"> - <TextBlock>Name</TextBlock> - <TextBox Margin="0 2 0 0" FontSize="20" Text="{Binding SlotName}"></TextBox> + <DockPanel> + <GroupBox DockPanel.Dock="Top" HorizontalAlignment="Left" Margin="50 10 10 10" Header="Environment Configuration" Padding="10 10 100 10"> + <StackPanel> + <CheckBox IsChecked="{Binding Config.IgnoreExistingSlot}" >Ignore Existing Deployment Slot</CheckBox> + <CheckBox Margin="0 5 0 0" IsChecked="{Binding Config.CreateEnvironmentGroup}" >Create Environment Group</CheckBox> + <CheckBox Margin="0 5 0 0" IsChecked="{Binding Config.AddEnvironmentGroupAdminUser}" >Add Creation User To Environment Group</CheckBox> + <CheckBox Margin="0 5 0 0" IsChecked="{Binding Config.CreateDeploymentSlot}" >Create Deployment Slot</CheckBox> + <CheckBox Margin="0 5 0 0" IsChecked="{Binding Config.CreateDatabase}" >Create Database</CheckBox> + <CheckBox Margin="0 5 0 0" IsChecked="{Binding Config.AddDatabasePermissionsForEnvironmentGroup}" >Add Database Permissions for Environment Group</CheckBox> + <CheckBox Margin="0 5 0 0" IsChecked="{Binding Config.CreateDatabaseBackupUser}" >Create Database Backup User</CheckBox> + <CheckBox Margin="0 5 0 0" IsChecked="{Binding Config.SynchronizeDatabaseSchema}">Synchronize Database Schema</CheckBox> + <CheckBox Margin="0 5 0 0" IsChecked="{Binding Config.SynchronizeDatabaseData}">Synchronize Database Static Collections</CheckBox> + <CheckBox Margin="0 5 0 0" IsChecked="{Binding Config.CreateStorageContainers}">Create MS and PPC Storage Containers</CheckBox> + <CheckBox Margin="0 5 0 0" IsChecked="{Binding Config.CopyStorageBlobs}">Copy Machine Studio and PPC Latest Version Blobs</CheckBox> + <CheckBox Margin="0 5 0 0" IsChecked="{Binding Config.CopyMachineServiceFiles}">Copy Machine Service Website Files</CheckBox> + </StackPanel> + </GroupBox> + + <StackPanel> + <GroupBox HorizontalAlignment="Left" Margin="50 10 10 10" Header="Environment Name/Credentials" Padding="10 10 100 10"> + <StackPanel HorizontalAlignment="Center" VerticalAlignment="Center" MinWidth="300"> + <TextBlock>Environment Name (e.g DEV)</TextBlock> + <TextBox Margin="0 2 0 0" FontSize="20" Text="{Binding SlotName}"></TextBox> - <TextBlock Margin="0 10 0 0">Active Directory Administrator Email</TextBlock> - <TextBox Margin="0 2 0 0" FontSize="20" Text="{Binding Email}"></TextBox> + <TextBlock Margin="0 10 0 0">Active Directory Administrator Email</TextBlock> + <TextBox Margin="0 2 0 0" FontSize="20" Text="{Binding Email}"></TextBox> - <TextBlock Margin="0 10 0 0">Password</TextBlock> - <PasswordBox Margin="0 2 0 0" FontSize="20" helpers:PasswordHelper.Attach="True" helpers:PasswordHelper.Password="{Binding Password,Mode=TwoWay}"></PasswordBox> + <TextBlock Margin="0 10 0 0">Password</TextBlock> + <PasswordBox Margin="0 2 0 0" FontSize="20" helpers:PasswordHelper.Attach="True" helpers:PasswordHelper.Password="{Binding Password,Mode=TwoWay}"></PasswordBox> + </StackPanel> + </GroupBox> - <Button Margin="0 40 0 0" Padding="20" Command="{Binding CreateDeploymentSlotCommand}">CREATE ENVIRONMENT</Button> - </StackPanel> + <Button HorizontalAlignment="Left" Width="420" Margin="50 40 0 0" Padding="20" Command="{Binding CreateEnvironmentCommand}">CREATE ENVIRONMENT</Button> + </StackPanel> + </DockPanel> </Grid> </Grid> </UserControl> diff --git a/Software/Visual_Studio/Azure/Tango.AzureUtils.UI/Views/EnvironmentUpgradeView.xaml b/Software/Visual_Studio/Azure/Tango.AzureUtils.UI/Views/EnvironmentUpgradeView.xaml index 6653653d0..113fd7b34 100644 --- a/Software/Visual_Studio/Azure/Tango.AzureUtils.UI/Views/EnvironmentUpgradeView.xaml +++ b/Software/Visual_Studio/Azure/Tango.AzureUtils.UI/Views/EnvironmentUpgradeView.xaml @@ -4,6 +4,7 @@ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:vm="clr-namespace:Tango.AzureUtils.UI.ViewModels" + xmlns:localControls="clr-namespace:Tango.AzureUtils.UI.Controls" xmlns:global="clr-namespace:Tango.AzureUtils.UI" xmlns:local="clr-namespace:Tango.AzureUtils.UI.Views" mc:Ignorable="d" @@ -22,15 +23,17 @@ <Grid> <GroupBox Header="Source App" Padding="10"> - <StackPanel> - <ComboBox ItemsSource="{Binding Apps}" SelectedItem="{Binding SelectedSourceApp}"> + <DockPanel> + <ComboBox DockPanel.Dock="Top" ItemsSource="{Binding Apps}" SelectedItem="{Binding SelectedSourceApp}"> <ComboBox.ItemTemplate> <DataTemplate> <TextBlock Text="{Binding Converter={StaticResource IWebAppBaseToDisplayNameConverter}}"></TextBlock> </DataTemplate> </ComboBox.ItemTemplate> </ComboBox> - </StackPanel> + + <localControls:WebAppPropertiesControl VerticalAlignment="Top" Margin="0 20 0 0" DataContext="{Binding SelectedSourceApp}" /> + </DockPanel> </GroupBox> </Grid> @@ -51,7 +54,7 @@ <StackPanel Margin="0 20 0 0"> <Button Padding="20" Command="{Binding ValidateUpgradeCommand}">Validate</Button> <StackPanel Margin="0 20 0 0" IsEnabled="{Binding CanUpgrade}"> - <Button Margin="0 10 0 0" Padding="20" Command="{Binding UpgradeEnvironmentCommand}">Full Upgrade</Button> + <Button Margin="0 10 0 0" Padding="20" Command="{Binding UpgradeEnvironmentCommand}">Upgrade Environment</Button> </StackPanel> </StackPanel> </StackPanel> @@ -59,15 +62,17 @@ <Grid Grid.Column="2"> <GroupBox Header="Target App" Padding="10"> - <StackPanel> - <ComboBox ItemsSource="{Binding Apps}" SelectedItem="{Binding SelectedTargetApp}"> + <DockPanel> + <ComboBox DockPanel.Dock="Top" ItemsSource="{Binding Apps}" SelectedItem="{Binding SelectedTargetApp}"> <ComboBox.ItemTemplate> <DataTemplate> <TextBlock Text="{Binding Converter={StaticResource IWebAppBaseToDisplayNameConverter}}"></TextBlock> </DataTemplate> </ComboBox.ItemTemplate> </ComboBox> - </StackPanel> + + <localControls:WebAppPropertiesControl VerticalAlignment="Top" Margin="0 20 0 0" DataContext="{Binding SelectedTargetApp}" /> + </DockPanel> </GroupBox> </Grid> </Grid> diff --git a/Software/Visual_Studio/Azure/Tango.AzureUtils.UI/Views/MainView.xaml b/Software/Visual_Studio/Azure/Tango.AzureUtils.UI/Views/MainView.xaml index fcef3e2ea..11749207e 100644 --- a/Software/Visual_Studio/Azure/Tango.AzureUtils.UI/Views/MainView.xaml +++ b/Software/Visual_Studio/Azure/Tango.AzureUtils.UI/Views/MainView.xaml @@ -24,7 +24,7 @@ <TextBlock VerticalAlignment="Center" HorizontalAlignment="Left" Margin="10 0 0 0" FontSize="50">Azure Utils</TextBlock> - <Button Command="{Binding InitCommand}" HorizontalAlignment="Right" VerticalAlignment="Center" Padding="30 10" Margin="10" FontSize="20">Authenticate</Button> + <Button Command="{Binding InitCommand}" HorizontalAlignment="Right" VerticalAlignment="Center" Padding="30 10" Margin="10">Authenticate</Button> <Grid Grid.Row="1" IsEnabled="{Binding IsInitialized}"> <TabControl Margin="10"> @@ -37,9 +37,19 @@ </TabControl> </Grid> - <Border Grid.Row="2" Background="{StaticResource SecondaryBackgroundBrush}" BorderBrush="{StaticResource LightBorderBrush}" BorderThickness="0 1 0 0"> + <Border Grid.Row="2" BorderBrush="{StaticResource LightBorderBrush}" BorderThickness="0 1 0 0"> + <Border.Style> + <Style TargetType="Border"> + <Setter Property="Background" Value="{StaticResource SecondaryBackgroundBrush}"></Setter> + <Style.Triggers> + <DataTrigger Binding="{Binding ElementName=state,Path=Text}" Value="Error"> + <Setter Property="Background" Value="#FCA4A4"></Setter> + </DataTrigger> + </Style.Triggers> + </Style> + </Border.Style> <DockPanel Margin="10 0"> - <TextBlock DockPanel.Dock="Top" VerticalAlignment="Center" FontSize="18" FontWeight="SemiBold" Text="{Binding Progress.Stage,Converter={StaticResource EnumToDescriptionConverter}}"></TextBlock> + <TextBlock x:Name="state" DockPanel.Dock="Top" VerticalAlignment="Center" FontSize="18" FontWeight="SemiBold" Text="{Binding Progress.Stage,Converter={StaticResource EnumToDescriptionConverter}}"></TextBlock> <StackPanel DockPanel.Dock="Top" VerticalAlignment="Bottom" Margin="0 0 0 5"> <TextBlock VerticalAlignment="Bottom" Text="{Binding Progress.Message}"></TextBlock> diff --git a/Software/Visual_Studio/Azure/Tango.AzureUtils/ExtensionMethods.cs b/Software/Visual_Studio/Azure/Tango.AzureUtils/ExtensionMethods.cs index b77745083..66d3f167a 100644 --- a/Software/Visual_Studio/Azure/Tango.AzureUtils/ExtensionMethods.cs +++ b/Software/Visual_Studio/Azure/Tango.AzureUtils/ExtensionMethods.cs @@ -10,22 +10,27 @@ using Tango.Core; public static class ExtensionMethods { - public static async Task<MachineServiceSettings> GetMachineServiceSettingsAsync(this IWebAppBase app) + public static async Task<MachineServiceSettings> GetMachineServiceSettingsAsync(this IWebAppBase app, bool throwOnMissing = true) { MachineServiceSettings settings = new MachineServiceSettings(); var s = await app.GetAppSettingsAsync(); - settings.DB_ADDRESS = s[nameof(MachineServiceSettings.DB_ADDRESS)].Value; - settings.DB_CATALOG = s[nameof(MachineServiceSettings.DB_CATALOG)].Value; - settings.DB_PASSWORD = s[nameof(MachineServiceSettings.DB_PASSWORD)].Value; - settings.DB_USER_NAME = s[nameof(MachineServiceSettings.DB_USER_NAME)].Value; - settings.DEPLOYMENT_SLOT = s[nameof(MachineServiceSettings.DEPLOYMENT_SLOT)].Value; - settings.ENFORCE_MACHINE_STUDIO_VERSION = s[nameof(MachineServiceSettings.ENFORCE_MACHINE_STUDIO_VERSION)].Value; - settings.ENVIRONMENT_GROUP = s[nameof(MachineServiceSettings.ENVIRONMENT_GROUP)].Value; - settings.MACHINE_STUDIO_VERSIONS_CONTAINER = s[nameof(MachineServiceSettings.MACHINE_STUDIO_VERSIONS_CONTAINER)].Value; - settings.STORAGE_ACCOUNT = s[nameof(MachineServiceSettings.STORAGE_ACCOUNT)].Value; - settings.TANGO_VERSIONS_CONTAINER = s[nameof(MachineServiceSettings.TANGO_VERSIONS_CONTAINER)].Value; + foreach (var prop in typeof(MachineServiceSettings).GetProperties()) + { + if (s.ContainsKey(prop.Name)) + { + prop.SetValue(settings, s[prop.Name].Value); + } + else if (throwOnMissing) + { + throw new KeyNotFoundException($"Missing application setting '{prop.Name}' on '{app.Name}'."); + } + else + { + prop.SetValue(settings, "N/A"); + } + } return settings; } |
