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 | |
| parent | 5bf3a7b36b3ccc7942f4e8e3fa227a38c04a8451 (diff) | |
| download | Tango-3d589c9f7dddd4c3b77b21fdd9930b6cf3f780ca.tar.gz Tango-3d589c9f7dddd4c3b77b21fdd9930b6cf3f780ca.zip | |
Working on azure utils.
Diffstat (limited to 'Software/Visual_Studio/Azure')
14 files changed, 440 insertions, 62 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> diff --git a/Software/Visual_Studio/Azure/Tango.AzureUtils/ActiveDirectory/ActiveDirectoryManager.cs b/Software/Visual_Studio/Azure/Tango.AzureUtils/ActiveDirectory/ActiveDirectoryManager.cs new file mode 100644 index 000000000..4527a1f53 --- /dev/null +++ b/Software/Visual_Studio/Azure/Tango.AzureUtils/ActiveDirectory/ActiveDirectoryManager.cs @@ -0,0 +1,96 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Microsoft.Azure.ActiveDirectory.GraphClient; +using Microsoft.Azure.Management.Fluent; +using Microsoft.IdentityModel.Clients.ActiveDirectory; + +namespace Tango.AzureUtils.ActiveDirectory +{ + public class ActiveDirectoryManager : AzureUtilsComponentBase + { + private AuthenticationResult _authResult; + private AzureUtilsCredentials _credentials; + private ActiveDirectoryClient _adClient; + + public ActiveDirectoryManager(IAzure azure, AzureUtilsCredentials credentials) : base(azure) + { + _credentials = credentials; + } + + public async Task Authenticate() + { + if (_authResult == null) + { + var authContext = new AuthenticationContext($"https://login.microsoftonline.com/{_credentials.TenantID}"); + ClientCredential clientCredentials = new ClientCredential(_credentials.ClientID, _credentials.ClientSecret); + _authResult = await authContext.AcquireTokenAsync("https://graph.windows.net/", clientCredentials); + } + } + + public async Task Authenticate(String email, String password) + { + if (_authResult == null) + { + var authContext = new AuthenticationContext($"https://login.microsoftonline.com/{_credentials.TenantID}"); + authContext.TokenCache.Clear(); + UserCredential userCredential = new UserPasswordCredential(email, password); + _authResult = await authContext.AcquireTokenAsync("https://graph.windows.net/", "ec612854-7abc-457b-808a-5d0c5ba80c57", userCredential); + } + } + + private ActiveDirectoryClient GetActiveDirectoryClient() + { + if (_adClient == null) + { + _adClient = new ActiveDirectoryClient(new Uri($"https://graph.windows.net/{_credentials.TenantID}"), async () => await Task.FromResult(_authResult.AccessToken)); + } + return _adClient; + } + + public async Task<bool> IsGroupExists(String name) + { + try + { + var client = GetActiveDirectoryClient(); + var g = await client.Groups.Where(x => x.DisplayName == name).Take(1).ExecuteSingleAsync(); + return g != null; + } + catch + { + return false; + } + } + + public async Task AddGroup(String name) + { + var client = GetActiveDirectoryClient(); + + await client.Groups.AddGroupAsync(new Group() + { + DisplayName = name, + MailEnabled = false, + MailNickname = Guid.NewGuid().ToString().ToLower(), + SecurityEnabled = true + }); + } + + public async Task AddUserToGroup(String group, String userEmail) + { + var client = GetActiveDirectoryClient(); + + List<Group> groups = new List<Group>(); + + var user = await client.Users.Where(x => x.UserPrincipalName == userEmail).ExecuteSingleAsync(); + + var g = await client.Groups.Where(x => x.DisplayName == group).Take(1).ExecuteSingleAsync(); + + var gg = g as Group; + + gg.Members.Add(user as DirectoryObject); + await gg.UpdateAsync(); + } + } +} diff --git a/Software/Visual_Studio/Azure/Tango.AzureUtils/AzureUtilsAuthenticationFactory.cs b/Software/Visual_Studio/Azure/Tango.AzureUtils/AzureUtilsAuthenticationFactory.cs index 4e37be13f..53a725047 100644 --- a/Software/Visual_Studio/Azure/Tango.AzureUtils/AzureUtilsAuthenticationFactory.cs +++ b/Software/Visual_Studio/Azure/Tango.AzureUtils/AzureUtilsAuthenticationFactory.cs @@ -11,20 +11,27 @@ namespace Tango.AzureUtils public class AzureUtilsAuthenticationFactory { private static IAzure _azure; + private static AzureUtilsCredentials credentials = new AzureUtilsCredentials() + { + ClientID = "be33437c-5052-449f-ab9d-a88d008eae24", + ClientSecret = "bf67fb6f-4d06-4893-988c-6b347aff23d6", + TenantID = "2ebd63a5-bc2f-41dc-9066-4409ed5e5dd4", + SubscriptionID = "10c8aa60-3b15-4e0d-b412-6aeef90e5e91" + }; - public static Task<IAzure> AuthenticateOrGetAsync(AzureUtilsCredentials creds) + public static Task<IAzure> AuthenticateOrGetAsync() { if (_azure == null) { return Task.Factory.StartNew<IAzure>(() => { - var credentials = SdkContext.AzureCredentialsFactory.FromServicePrincipal( - creds.ClientID, - creds.ClientSecret, - creds.TenantID, + var creds = SdkContext.AzureCredentialsFactory.FromServicePrincipal( + credentials.ClientID, + credentials.ClientSecret, + credentials.TenantID, AzureEnvironment.AzureGlobalCloud); - _azure = Azure.Authenticate(credentials).WithSubscription(creds.SubscriptionID); + _azure = Azure.Authenticate(creds).WithSubscription(credentials.SubscriptionID); return _azure; }); } @@ -33,5 +40,10 @@ namespace Tango.AzureUtils return Task.FromResult(_azure); } } + + public static AzureUtilsCredentials GetCredentials() + { + return credentials; + } } } diff --git a/Software/Visual_Studio/Azure/Tango.AzureUtils/AzureUtilsStage.cs b/Software/Visual_Studio/Azure/Tango.AzureUtils/AzureUtilsStage.cs index f7e0c1cd4..3364dc8c7 100644 --- a/Software/Visual_Studio/Azure/Tango.AzureUtils/AzureUtilsStage.cs +++ b/Software/Visual_Studio/Azure/Tango.AzureUtils/AzureUtilsStage.cs @@ -11,10 +11,13 @@ namespace Tango.AzureUtils Ready, Initializing, Error, + Validating, //Deployment - Validating, DownloadingFTP, UploadingFTP, + + //Environment + Creating, } } diff --git a/Software/Visual_Studio/Azure/Tango.AzureUtils/Deployment/DeploymentManager.cs b/Software/Visual_Studio/Azure/Tango.AzureUtils/Deployment/DeploymentManager.cs index 782466c37..3c27d8e01 100644 --- a/Software/Visual_Studio/Azure/Tango.AzureUtils/Deployment/DeploymentManager.cs +++ b/Software/Visual_Studio/Azure/Tango.AzureUtils/Deployment/DeploymentManager.cs @@ -362,35 +362,6 @@ namespace Tango.AzureUtils.Deployment #endregion - #region Deployment Slots - - public async Task<IDeploymentSlot> AddDeploymentSlot(IWebApp app, IDeploymentSlot existingSlot, String name, MachineServiceSettings settings) - { - var slot = app.DeploymentSlots.Define(name); - IWithCreate<IDeploymentSlot> toCreate = null; - - if (existingSlot != null) - { - toCreate = slot.WithConfigurationFromDeploymentSlot(existingSlot); - } - else - { - toCreate = slot.WithBrandNewConfiguration(); - } - - var dictionary = new Dictionary<string, string>(); - dictionary.Add(nameof(MachineServiceSettings.DB_ADDRESS), settings.DB_ADDRESS); - dictionary.Add(nameof(MachineServiceSettings.DB_ADDRESS), settings.DB_ADDRESS); - dictionary.Add(nameof(MachineServiceSettings.DB_CATALOG), settings.DB_CATALOG); - dictionary.Add(nameof(MachineServiceSettings.DB_USER_NAME), settings.DB_USER_NAME); - - var result = await toCreate.CreateAsync(); - - return result; - } - - #endregion - #region Validation public async Task ValidateUpgrade(IWebAppBase sourceApp, IWebAppBase targetApp) diff --git a/Software/Visual_Studio/Azure/Tango.AzureUtils/Environment/EnvironmentManager.cs b/Software/Visual_Studio/Azure/Tango.AzureUtils/Environment/EnvironmentManager.cs new file mode 100644 index 000000000..c7e48fab1 --- /dev/null +++ b/Software/Visual_Studio/Azure/Tango.AzureUtils/Environment/EnvironmentManager.cs @@ -0,0 +1,108 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Microsoft.Azure; +using Microsoft.Azure.Management.AppService.Fluent; +using Microsoft.Azure.Management.Fluent; +using Microsoft.Azure.Management.RecoveryServices.Backup; +using Microsoft.Azure.Management.Sql.Fluent.Models; +using Microsoft.WindowsAzure.Storage; +using Tango.AzureUtils.ActiveDirectory; +using Tango.AzureUtils.Deployment; +using Tango.Core.DB; + +namespace Tango.AzureUtils.Environment +{ + public class EnvironmentManager : AzureUtilsComponentBase + { + private ActiveDirectoryManager _adManager; + + public EnvironmentManager(IAzure azure, ActiveDirectoryManager activeDirectoryManager) : base(azure) + { + _adManager = activeDirectoryManager; + } + + #region Deployment Slots + + public async Task<IDeploymentSlot> CreateDeploymentSlot(IWebApp app, IDeploymentSlot existingSlot, String name, String adEmail, String adPassword) + { + var settings = await existingSlot.GetMachineServiceSettingsAsync(); + + String dbCatalog = $"Tango_{name}"; + String machineStudioContainerName = $"machine-studio-versions-{name.ToLower()}"; + String ppcContainerName = $"tango-versions-{name.ToLower()}"; + String machineServiceBackupsContainerName = $"machine-service-backups-{name.ToLower()}"; + String machineServiceLogsContainerName = $"machine-service-logs-{name.ToLower()}"; + String environmentGroupName = $"Tango {name}"; + + await _adManager.Authenticate(adEmail, adPassword); + + if (!await _adManager.IsGroupExists(environmentGroupName)) + { + await _adManager.AddGroup(environmentGroupName); + await _adManager.AddUserToGroup(environmentGroupName, adEmail); + } + + return new object() as IDeploymentSlot; + + var dictionary = new Dictionary<string, string>(); + dictionary.Add(nameof(MachineServiceSettings.DB_ADDRESS), settings.DB_ADDRESS); + dictionary.Add(nameof(MachineServiceSettings.DB_CATALOG), dbCatalog); + dictionary.Add(nameof(MachineServiceSettings.DB_PASSWORD), settings.DB_PASSWORD); + dictionary.Add(nameof(MachineServiceSettings.DB_USER_NAME), settings.DB_USER_NAME); + dictionary.Add(nameof(MachineServiceSettings.DEPLOYMENT_SLOT), name); + dictionary.Add(nameof(MachineServiceSettings.ENFORCE_MACHINE_STUDIO_VERSION), settings.ENFORCE_MACHINE_STUDIO_VERSION); + dictionary.Add(nameof(MachineServiceSettings.ENVIRONMENT_GROUP), environmentGroupName); + dictionary.Add(nameof(MachineServiceSettings.STORAGE_ACCOUNT), settings.STORAGE_ACCOUNT); + dictionary.Add(nameof(MachineServiceSettings.MACHINE_STUDIO_VERSIONS_CONTAINER), machineStudioContainerName); + dictionary.Add(nameof(MachineServiceSettings.TANGO_VERSIONS_CONTAINER), ppcContainerName); + + //Add Slot + var slot = await app.DeploymentSlots + .Define(app.Name + "-" + name) + .WithBrandNewConfiguration() + .WithWebAppAlwaysOn(true) + .WithWebSocketsEnabled(true) + .WithStickyAppSettings(dictionary) + .WithStickyConnectionString(dbCatalog, $"Server=tcp:twine.database.windows.net,1433;Initial Catalog={dbCatalog};Persist Security Info=False;User ID=BackupUser;Password=Aa123456;MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;", Microsoft.Azure.Management.AppService.Fluent.Models.ConnectionStringType.SQLAzure) + .CreateAsync(); + + //Add Database + var sqlServer = (await Azure.SqlServers.ListAsync()).SingleOrDefault(x => x.Name == "twine"); + var database = await sqlServer.Databases.Define(dbCatalog).WithEdition(DatabaseEdition.Standard).CreateAsync(); + + using (DbManager db = DbManager.FromCredentials(settings.DB_ADDRESS, dbCatalog, settings.DB_USER_NAME, settings.DB_PASSWORD)) + { + await db.ExecuteCommandAsync("CREATE USER [BackupUser] FOR LOGIN [BackupUser] WITH DEFAULT_SCHEMA=[dbo]"); + await db.ExecuteCommandAsync("EXEC sp_addrolemember N'db_owner', N'BackupUser'"); + await db.ExecuteCommandAsync("EXEC sp_addrolemember N'db_accessadmin', N'BackupUser'"); + await db.ExecuteCommandAsync("EXEC sp_addrolemember N'db_securityadmin', N'BackupUser'"); + await db.ExecuteCommandAsync("EXEC sp_addrolemember N'db_backupoperator', N'BackupUser'"); + await db.ExecuteCommandAsync("EXEC sp_addrolemember N'db_datareader', N'BackupUser'"); + await db.ExecuteCommandAsync("EXEC sp_addrolemember N'db_datawriter', N'BackupUser'"); + } + + //Add Storage Containers + var targetAccount = CloudStorageAccount.Parse(settings.STORAGE_ACCOUNT); + var targetClient = targetAccount.CreateCloudBlobClient(); + + var machineStudioContainer = targetClient.GetContainerReference(machineStudioContainerName); + await machineStudioContainer.CreateIfNotExistsAsync(); + + var ppcContainer = targetClient.GetContainerReference(ppcContainerName); + await ppcContainer.CreateIfNotExistsAsync(); + + var machineServiceBackupsContainer = targetClient.GetContainerReference(machineServiceBackupsContainerName); + await machineServiceBackupsContainer.CreateIfNotExistsAsync(); + + var machineServiceLogsContainer = targetClient.GetContainerReference(machineServiceLogsContainerName); + await machineServiceLogsContainer.CreateIfNotExistsAsync(); + + return slot; + } + + #endregion + } +} diff --git a/Software/Visual_Studio/Azure/Tango.AzureUtils/Deployment/ExtensionMethods.cs b/Software/Visual_Studio/Azure/Tango.AzureUtils/ExtensionMethods.cs index 938717b43..b77745083 100644 --- a/Software/Visual_Studio/Azure/Tango.AzureUtils/Deployment/ExtensionMethods.cs +++ b/Software/Visual_Studio/Azure/Tango.AzureUtils/ExtensionMethods.cs @@ -4,6 +4,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using Tango.AzureUtils; using Tango.AzureUtils.Deployment; using Tango.Core; @@ -17,12 +18,14 @@ public static class ExtensionMethods settings.DB_ADDRESS = s[nameof(MachineServiceSettings.DB_ADDRESS)].Value; settings.DB_CATALOG = s[nameof(MachineServiceSettings.DB_CATALOG)].Value; - settings.DB_USER_NAME = s[nameof(MachineServiceSettings.DB_USER_NAME)].Value; settings.DB_PASSWORD = s[nameof(MachineServiceSettings.DB_PASSWORD)].Value; - settings.STORAGE_ACCOUNT = s[nameof(MachineServiceSettings.STORAGE_ACCOUNT)].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; - settings.ENVIRONMENT_GROUP = s[nameof(MachineServiceSettings.ENVIRONMENT_GROUP)].Value; return settings; } diff --git a/Software/Visual_Studio/Azure/Tango.AzureUtils/Deployment/MachineServiceSettings.cs b/Software/Visual_Studio/Azure/Tango.AzureUtils/MachineServiceSettings.cs index 7becb86df..93065c50d 100644 --- a/Software/Visual_Studio/Azure/Tango.AzureUtils/Deployment/MachineServiceSettings.cs +++ b/Software/Visual_Studio/Azure/Tango.AzureUtils/MachineServiceSettings.cs @@ -4,17 +4,19 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -namespace Tango.AzureUtils.Deployment +namespace Tango.AzureUtils { public class MachineServiceSettings { public String DB_ADDRESS { get; set; } public String DB_CATALOG { get; set; } - public String DB_USER_NAME { get; set; } public String DB_PASSWORD { get; set; } + public String DB_USER_NAME { get; set; } + public String DEPLOYMENT_SLOT { get; set; } + public String ENFORCE_MACHINE_STUDIO_VERSION { get; set; } + public String ENVIRONMENT_GROUP { get; set; } + public String MACHINE_STUDIO_VERSIONS_CONTAINER { get; set; } public String STORAGE_ACCOUNT { get; set; } public String TANGO_VERSIONS_CONTAINER { get; set; } - public String MACHINE_STUDIO_VERSIONS_CONTAINER { get; set; } - public String ENVIRONMENT_GROUP { get; set; } } } diff --git a/Software/Visual_Studio/Azure/Tango.AzureUtils/Tango.AzureUtils.csproj b/Software/Visual_Studio/Azure/Tango.AzureUtils/Tango.AzureUtils.csproj index cc9417c18..77547a85c 100644 --- a/Software/Visual_Studio/Azure/Tango.AzureUtils/Tango.AzureUtils.csproj +++ b/Software/Visual_Studio/Azure/Tango.AzureUtils/Tango.AzureUtils.csproj @@ -43,6 +43,9 @@ <Reference Include="Hyak.Common, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL"> <HintPath>..\..\packages\Hyak.Common.1.2.2\lib\net452\Hyak.Common.dll</HintPath> </Reference> + <Reference Include="Microsoft.Azure.ActiveDirectory.GraphClient, Version=2.1.10.0, Culture=neutral, processorArchitecture=MSIL"> + <HintPath>..\..\packages\Microsoft.Azure.ActiveDirectory.GraphClient.2.1.1\lib\portable-net4+sl5+win+wpa+wp8\Microsoft.Azure.ActiveDirectory.GraphClient.dll</HintPath> + </Reference> <Reference Include="Microsoft.Azure.Common, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL"> <HintPath>..\..\packages\Microsoft.Azure.Common.2.2.1\lib\net452\Microsoft.Azure.Common.dll</HintPath> </Reference> @@ -109,6 +112,9 @@ <Reference Include="Microsoft.Azure.Management.PrivateDns.Fluent, Version=1.0.0.63, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL"> <HintPath>..\..\packages\Microsoft.Azure.Management.PrivateDns.Fluent.1.30.0\lib\net452\Microsoft.Azure.Management.PrivateDns.Fluent.dll</HintPath> </Reference> + <Reference Include="Microsoft.Azure.Management.RecoveryServices.Backup, Version=0.9.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL"> + <HintPath>..\..\packages\Microsoft.Azure.Management.RecoveryServices.Backup.0.1.2\lib\net40\Microsoft.Azure.Management.RecoveryServices.Backup.dll</HintPath> + </Reference> <Reference Include="Microsoft.Azure.Management.Redis.Fluent, Version=1.0.0.63, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL"> <HintPath>..\..\packages\Microsoft.Azure.Management.Redis.Fluent.1.30.0\lib\net452\Microsoft.Azure.Management.Redis.Fluent.dll</HintPath> </Reference> @@ -136,6 +142,15 @@ <Reference Include="Microsoft.Azure.Storage.Common, Version=11.1.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL"> <HintPath>..\..\packages\Microsoft.Azure.Storage.Common.11.1.2\lib\net452\Microsoft.Azure.Storage.Common.dll</HintPath> </Reference> + <Reference Include="Microsoft.Data.Edm, Version=5.6.4.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL"> + <HintPath>..\..\packages\Microsoft.Data.Edm.5.6.4\lib\net40\Microsoft.Data.Edm.dll</HintPath> + </Reference> + <Reference Include="Microsoft.Data.OData, Version=5.6.4.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL"> + <HintPath>..\..\packages\Microsoft.Data.OData.5.6.4\lib\net40\Microsoft.Data.OData.dll</HintPath> + </Reference> + <Reference Include="Microsoft.Data.Services.Client, Version=5.6.4.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL"> + <HintPath>..\..\packages\Microsoft.Data.Services.Client.5.6.4\lib\net40\Microsoft.Data.Services.Client.dll</HintPath> + </Reference> <Reference Include="Microsoft.IdentityModel.Clients.ActiveDirectory, Version=4.3.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL"> <HintPath>..\..\packages\Microsoft.IdentityModel.Clients.ActiveDirectory.4.3.0\lib\net45\Microsoft.IdentityModel.Clients.ActiveDirectory.dll</HintPath> </Reference> @@ -164,15 +179,39 @@ <HintPath>..\..\packages\Newtonsoft.Json.10.0.3\lib\net45\Newtonsoft.Json.dll</HintPath> </Reference> <Reference Include="System" /> + <Reference Include="System.Buffers, Version=4.0.2.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL"> + <HintPath>..\..\packages\System.Buffers.4.4.0\lib\netstandard2.0\System.Buffers.dll</HintPath> + </Reference> <Reference Include="System.ComponentModel.DataAnnotations" /> <Reference Include="System.Core" /> + <Reference Include="System.Diagnostics.DiagnosticSource, Version=4.0.4.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL"> + <HintPath>..\..\packages\System.Diagnostics.DiagnosticSource.4.6.0\lib\net46\System.Diagnostics.DiagnosticSource.dll</HintPath> + </Reference> <Reference Include="System.Drawing" /> <Reference Include="System.IdentityModel" /> + <Reference Include="System.Memory, Version=4.0.1.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL"> + <HintPath>..\..\packages\System.Memory.4.5.3\lib\netstandard2.0\System.Memory.dll</HintPath> + </Reference> <Reference Include="System.Net" /> <Reference Include="System.Net.Http.WebRequest" /> + <Reference Include="System.Numerics" /> + <Reference Include="System.Numerics.Vectors, Version=4.1.3.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"> + <HintPath>..\..\packages\System.Numerics.Vectors.4.4.0\lib\net46\System.Numerics.Vectors.dll</HintPath> + </Reference> <Reference Include="System.Runtime" /> + <Reference Include="System.Runtime.CompilerServices.Unsafe, Version=4.0.4.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"> + <HintPath>..\..\packages\System.Runtime.CompilerServices.Unsafe.4.5.2\lib\netstandard2.0\System.Runtime.CompilerServices.Unsafe.dll</HintPath> + </Reference> <Reference Include="System.Runtime.Serialization" /> <Reference Include="System.Security" /> + <Reference Include="System.Spatial, Version=5.6.4.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL"> + <HintPath>..\..\packages\System.Spatial.5.6.4\lib\net40\System.Spatial.dll</HintPath> + </Reference> + <Reference Include="System.ValueTuple, Version=4.0.1.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL"> + <HintPath>..\..\packages\System.ValueTuple.4.3.0\lib\netstandard1.0\System.ValueTuple.dll</HintPath> + <Private>True</Private> + <Private>True</Private> + </Reference> <Reference Include="System.Web" /> <Reference Include="System.Windows.Forms" /> <Reference Include="System.Xml.Linq" /> @@ -183,15 +222,17 @@ <Reference Include="System.Xml" /> </ItemGroup> <ItemGroup> + <Compile Include="ActiveDirectory\ActiveDirectoryManager.cs" /> <Compile Include="AzureUtilsAuthenticationFactory.cs" /> <Compile Include="AzureUtilsComponentBase.cs" /> <Compile Include="AzureUtilsCredentials.cs" /> <Compile Include="Deployment\DeploymentManager.cs" /> <Compile Include="AzureUtilsProgressEventArgs.cs" /> <Compile Include="AzureUtilsStage.cs" /> - <Compile Include="Deployment\ExtensionMethods.cs" /> - <Compile Include="Deployment\MachineServiceSettings.cs" /> + <Compile Include="ExtensionMethods.cs" /> + <Compile Include="MachineServiceSettings.cs" /> <Compile Include="Deployment\UpgradeConfiguration.cs" /> + <Compile Include="Environment\EnvironmentManager.cs" /> <Compile Include="Properties\AssemblyInfo.cs" /> </ItemGroup> <ItemGroup> diff --git a/Software/Visual_Studio/Azure/Tango.AzureUtils/app.config b/Software/Visual_Studio/Azure/Tango.AzureUtils/app.config index 0c152335c..9c4bc82cf 100644 --- a/Software/Visual_Studio/Azure/Tango.AzureUtils/app.config +++ b/Software/Visual_Studio/Azure/Tango.AzureUtils/app.config @@ -14,6 +14,26 @@ <assemblyIdentity name="Microsoft.IdentityModel.Clients.ActiveDirectory" publicKeyToken="31bf3856ad364e35" culture="neutral" /> <bindingRedirect oldVersion="0.0.0.0-4.3.0.0" newVersion="4.3.0.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> + <dependentAssembly> + <assemblyIdentity name="System.ValueTuple" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-4.0.2.0" newVersion="4.0.2.0" /> + </dependentAssembly> </assemblyBinding> </runtime> <entityFramework> diff --git a/Software/Visual_Studio/Azure/Tango.AzureUtils/packages.config b/Software/Visual_Studio/Azure/Tango.AzureUtils/packages.config index 9d0723d02..16c9a9e88 100644 --- a/Software/Visual_Studio/Azure/Tango.AzureUtils/packages.config +++ b/Software/Visual_Studio/Azure/Tango.AzureUtils/packages.config @@ -3,6 +3,7 @@ <package id="EntityFramework" version="6.2.0" targetFramework="net461" /> <package id="FluentFTP" version="30.0.0" targetFramework="net461" /> <package id="Hyak.Common" version="1.2.2" targetFramework="net461" /> + <package id="Microsoft.Azure.ActiveDirectory.GraphClient" version="2.1.1" targetFramework="net461" /> <package id="Microsoft.Azure.Common" version="2.2.1" targetFramework="net461" /> <package id="Microsoft.Azure.KeyVault" version="3.0.1" targetFramework="net461" /> <package id="Microsoft.Azure.KeyVault.Core" version="1.0.0" targetFramework="net461" /> @@ -25,6 +26,7 @@ <package id="Microsoft.Azure.Management.Msi.Fluent" version="1.30.0" targetFramework="net461" /> <package id="Microsoft.Azure.Management.Network.Fluent" version="1.30.0" targetFramework="net461" /> <package id="Microsoft.Azure.Management.PrivateDns.Fluent" version="1.30.0" targetFramework="net461" /> + <package id="Microsoft.Azure.Management.RecoveryServices.Backup" version="0.1.2" targetFramework="net461" /> <package id="Microsoft.Azure.Management.Redis.Fluent" version="1.30.0" targetFramework="net461" /> <package id="Microsoft.Azure.Management.ResourceManager.Fluent" version="1.30.0" targetFramework="net461" /> <package id="Microsoft.Azure.Management.Search.Fluent" version="1.30.0" targetFramework="net461" /> @@ -34,6 +36,9 @@ <package id="Microsoft.Azure.Management.TrafficManager.Fluent" version="1.30.0" targetFramework="net461" /> <package id="Microsoft.Azure.Storage.Blob" version="11.1.2" targetFramework="net461" /> <package id="Microsoft.Azure.Storage.Common" version="11.1.2" targetFramework="net461" /> + <package id="Microsoft.Data.Edm" version="5.6.4" targetFramework="net461" /> + <package id="Microsoft.Data.OData" version="5.6.4" targetFramework="net461" /> + <package id="Microsoft.Data.Services.Client" version="5.6.4" targetFramework="net461" /> <package id="Microsoft.IdentityModel.Clients.ActiveDirectory" version="4.3.0" targetFramework="net461" /> <package id="Microsoft.IdentityModel.Logging" version="1.1.2" targetFramework="net461" /> <package id="Microsoft.IdentityModel.Tokens" version="5.1.2" targetFramework="net461" /> @@ -42,5 +47,12 @@ <package id="Microsoft.Rest.ClientRuntime.Azure.Authentication" version="2.4.0" targetFramework="net461" /> <package id="Microsoft.WindowsAzure.ConfigurationManager" version="3.2.3" targetFramework="net461" /> <package id="Newtonsoft.Json" version="10.0.3" targetFramework="net461" /> + <package id="System.Buffers" version="4.4.0" targetFramework="net461" /> + <package id="System.Diagnostics.DiagnosticSource" version="4.6.0" targetFramework="net461" /> + <package id="System.Memory" version="4.5.3" targetFramework="net461" /> + <package id="System.Numerics.Vectors" version="4.4.0" targetFramework="net461" /> + <package id="System.Runtime.CompilerServices.Unsafe" version="4.5.2" targetFramework="net461" /> + <package id="System.Spatial" version="5.6.4" targetFramework="net461" /> + <package id="System.ValueTuple" version="4.3.0" targetFramework="net461" /> <package id="WindowsAzure.Storage" version="9.3.3" targetFramework="net461" /> </packages>
\ No newline at end of file |
