diff options
| author | Roy Ben-Shabat <Roy@Twine-s.com> | 2020-02-04 20:19:42 +0200 |
|---|---|---|
| committer | Roy Ben-Shabat <Roy@Twine-s.com> | 2020-02-04 20:19:42 +0200 |
| commit | 3d589c9f7dddd4c3b77b21fdd9930b6cf3f780ca (patch) | |
| tree | 20faf3a19037c22519ba65e0e758ca0ec9db737f /Software/Visual_Studio/Azure/Tango.AzureUtils.UI | |
| parent | 5bf3a7b36b3ccc7942f4e8e3fa227a38c04a8451 (diff) | |
| download | Tango-3d589c9f7dddd4c3b77b21fdd9930b6cf3f780ca.tar.gz Tango-3d589c9f7dddd4c3b77b21fdd9930b6cf3f780ca.zip | |
Working on azure utils.
Diffstat (limited to 'Software/Visual_Studio/Azure/Tango.AzureUtils.UI')
4 files changed, 127 insertions, 17 deletions
diff --git a/Software/Visual_Studio/Azure/Tango.AzureUtils.UI/App.config b/Software/Visual_Studio/Azure/Tango.AzureUtils.UI/App.config index 26e48b10f..f97c59da6 100644 --- a/Software/Visual_Studio/Azure/Tango.AzureUtils.UI/App.config +++ b/Software/Visual_Studio/Azure/Tango.AzureUtils.UI/App.config @@ -57,6 +57,22 @@ <assemblyIdentity name="System.Diagnostics.StackTrace" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> <bindingRedirect oldVersion="0.0.0.0-4.0.3.0" newVersion="4.0.3.0" /> </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="Microsoft.Data.Services.Client" publicKeyToken="31bf3856ad364e35" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-5.6.4.0" newVersion="5.6.4.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="Microsoft.Data.Edm" publicKeyToken="31bf3856ad364e35" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-5.6.4.0" newVersion="5.6.4.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="Microsoft.Data.OData" publicKeyToken="31bf3856ad364e35" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-5.6.4.0" newVersion="5.6.4.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="System.Memory" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-4.0.1.1" newVersion="4.0.1.1" /> + </dependentAssembly> </assemblyBinding> </runtime> <entityFramework> 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 919e361e1..5a1fa8cca 100644 --- a/Software/Visual_Studio/Azure/Tango.AzureUtils.UI/ViewModels/EnvironmentCreationViewVM.cs +++ b/Software/Visual_Studio/Azure/Tango.AzureUtils.UI/ViewModels/EnvironmentCreationViewVM.cs @@ -1,23 +1,104 @@ using System; using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; using System.Linq; using System.Text; using System.Threading.Tasks; using Microsoft.Azure.Management.AppService.Fluent; using Microsoft.Azure.Management.Fluent; +using Tango.AzureUtils.ActiveDirectory; +using Tango.AzureUtils.Deployment; +using Tango.AzureUtils.Environment; +using Tango.Core.Commands; namespace Tango.AzureUtils.UI.ViewModels { public class EnvironmentCreationViewVM : AzureDashboardViewModel { + private IWebAppBase _machineServiceApp; + private EnvironmentManager _environmentManager; + + private List<IDeploymentSlot> _deploymentSlots; + public List<IDeploymentSlot> DeploymentSlots + { + get { return _deploymentSlots; } + set { _deploymentSlots = value; RaisePropertyChangedAuto(); } + } + + private IDeploymentSlot _selectedDeploymentSlot; + public IDeploymentSlot SelectedDeploymentSlot + { + get { return _selectedDeploymentSlot; } + set { _selectedDeploymentSlot = value; RaisePropertyChangedAuto(); } + } + + private String _slotName; + [Required] + public String SlotName + { + get { return _slotName; } + set { _slotName = value; RaisePropertyChangedAuto(); } + } + + private String _email; + [Required] + [EmailAddress] + public String Email + { + get { return _email; } + set { _email = value; RaisePropertyChangedAuto(); } + } + + private String _password; + [Required] + public String Password + { + get { return _password; } + set { _password = value; RaisePropertyChangedAuto(); } + } + + public RelayCommand CreateDeploymentSlotCommand { get; set; } + + public EnvironmentCreationViewVM() + { + CreateDeploymentSlotCommand = new RelayCommand(CreateDeploymentSlot); + } + public override void OnApplicationReady() { - + Email = "roy@twine-s.com"; + Password = "1Creativity"; + SlotName = "ROY"; } public override void OnAuthenticated(IAzure azure, List<IWebAppBase> apps) { - + _machineServiceApp = apps.SingleOrDefault(x => x.Name == "MachineService"); + DeploymentSlots = apps.OfType<IDeploymentSlot>().Where(x => x.Parent == _machineServiceApp).ToList(); + SelectedDeploymentSlot = DeploymentSlots.FirstOrDefault(); + + _environmentManager = new EnvironmentManager(azure, new ActiveDirectoryManager(azure, AzureUtilsAuthenticationFactory.GetCredentials())); + } + + private async void CreateDeploymentSlot() + { + try + { + if (!Validate()) return; + + IsFree = false; + StatusManager.UpdateStatus(AzureUtilsStage.Creating, "Creating new deployment slot...", true); + await _environmentManager.CreateDeploymentSlot(_machineServiceApp as IWebApp, SelectedDeploymentSlot, SlotName, Email, Password); + StatusManager.UpdateStatus(AzureUtilsStage.Ready, "Deployment slot created successfully."); + } + catch (Exception ex) + { + StatusManager.UpdateStatus(ex); + } + finally + { + IsFree = true; + } } } } diff --git a/Software/Visual_Studio/Azure/Tango.AzureUtils.UI/ViewModels/MainViewVM.cs b/Software/Visual_Studio/Azure/Tango.AzureUtils.UI/ViewModels/MainViewVM.cs index 958d1b857..4faf1369f 100644 --- a/Software/Visual_Studio/Azure/Tango.AzureUtils.UI/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/Azure/Tango.AzureUtils.UI/ViewModels/MainViewVM.cs @@ -16,11 +16,6 @@ namespace Tango.AzureUtils.UI.ViewModels { public class MainViewVM : AzureDashboardViewModel { - private static string app_id = "be33437c-5052-449f-ab9d-a88d008eae24"; - private static string client_secret = "bf67fb6f-4d06-4893-988c-6b347aff23d6"; - private static string tenant_id = "2ebd63a5-bc2f-41dc-9066-4409ed5e5dd4"; - private static string subscription_id = "10c8aa60-3b15-4e0d-b412-6aeef90e5e91"; - private IAzure _azure; #region Properties @@ -70,13 +65,7 @@ namespace Tango.AzureUtils.UI.ViewModels IsFree = false; StatusManager.UpdateStatus(AzureUtilsStage.Initializing, "Authenticating...", true); - _azure = await AzureUtilsAuthenticationFactory.AuthenticateOrGetAsync(new AzureUtilsCredentials() - { - ClientID = app_id, - ClientSecret = client_secret, - TenantID = tenant_id, - SubscriptionID = subscription_id - }); + _azure = await AzureUtilsAuthenticationFactory.AuthenticateOrGetAsync(); List<IWebAppBase> allApps = new List<IWebAppBase>(); 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 6c886deb7..4c899bf2d 100644 --- a/Software/Visual_Studio/Azure/Tango.AzureUtils.UI/Views/EnvironmentCreationView.xaml +++ b/Software/Visual_Studio/Azure/Tango.AzureUtils.UI/Views/EnvironmentCreationView.xaml @@ -9,11 +9,35 @@ mc:Ignorable="d" d:DesignHeight="700" d:DesignWidth="1100" - d:DataContext="{d:DesignInstance Type=vm:EnvironmentUpgradeViewVM, IsDesignTimeCreatable=False}" - DataContext="{x:Static global:ViewModelLocator.EnvironmentUpgradeViewVM}" + d:DataContext="{d:DesignInstance Type=vm:EnvironmentCreationViewVM, IsDesignTimeCreatable=False}" + DataContext="{x:Static global:ViewModelLocator.EnvironmentCreationViewVM}" Background="{StaticResource PrimaryBackgroundBrush}" Foreground="{StaticResource PrimaryForegroundBrush}"> <Grid> - + <Grid.ColumnDefinitions> + <ColumnDefinition Width="300"/> + <ColumnDefinition Width="1*"/> + </Grid.ColumnDefinitions> + + <GroupBox Header="Source Deployment Slot" Padding="5"> + <StackPanel> + <ComboBox ItemsSource="{Binding DeploymentSlots}" SelectedItem="{Binding SelectedDeploymentSlot}" DisplayMemberPath="Name"></ComboBox> + </StackPanel> + </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> + + <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> + <TextBox Margin="0 2 0 0" FontSize="20" Text="{Binding Password}"></TextBox> + + <Button Margin="0 40 0 0" Padding="20" Command="{Binding CreateDeploymentSlotCommand}">CREATE DEPLOYMENT SLOT</Button> + </StackPanel> + </Grid> </Grid> </UserControl> |
