public async Task UpdateSubscriptions(string userAccount) { LogMethodEntry(); await PerformWorkAsync(null, async() => { var subscriptions = await AzureHelper.GetSubscriptionsAsync(_id, userAccount); cbSubscriptions.Items.Clear(); cbSubscriptions.Items.Add(""); foreach (var sub in subscriptions.OrderBy(s => s.SubscriptionName)) { cbSubscriptions.Items.Add(sub); } cbSubscriptions.ValueMember = "SubscriptionName"; UpdateFormState(); }); }
private async void HandleAuthenticateClicked(object sender, EventArgs e) { LogMethodEntry(); await PerformWorkAsync(null, async() => { AuthenticationResult auth = null; try { auth = AzureHelper.GetAuthentication("main", null, true); } catch (AdalException aex) { Logger.Error(aex.Message); return; } IsAuthenticated = true; lblLoggedInUser.Text = auth.UserInfo.DisplayableId; foreach (var control in tabControl1.TabPages.OfType <TabPage>().SelectMany(p => p.Controls.OfType <DeployControl>())) { this.UpdateControlEnabledState(control, true); await control.UpdateSubscriptions(lblLoggedInUser.Text); } }); }
private async Task HandleSubscriptionIndexChangedAsync(object sender, EventArgs e, string locationFilter = null) { LogMethodEntry(); await PerformWorkAsync(null, async() => { var subscription = cbSubscriptions.SelectedItem as SubscriptionListOperationResponse.Subscription; if (subscription == null) { return; } // Clear currently selected files ClearAllSelectedFiles(); // Load cloudservices and storageaccounts var hostedservicesTask = AzureHelper.GetCloudservicesAsync(_id, subscription); var storageaccountsTask = AzureHelper.GetStorageAccountsAsync(_id, subscription); await Task.WhenAll(hostedservicesTask, storageaccountsTask); // Update cloudservices var hostedservices = hostedservicesTask.Result; cbCloudservices.Items.Clear(); foreach (var hostedService in hostedservices.OrderBy(hostedService => hostedService.ServiceName)) { if (ShouldFilter(locationFilter, hostedService.Properties.Location, hostedService.Properties.ExtendedProperties)) { continue; } cbCloudservices.Items.Add(hostedService); } cbCloudservices.ValueMember = "ServiceName"; if (locationFilter == null) { var locations = hostedservices.Select(hostedService => hostedService.Properties.Location).Where(location => location != null).Distinct().OrderBy(name => name).ToList(); cbLocations.Items.Clear(); if (locations.Count > 1) { cbLocations.Items.Add("<ALL>"); foreach (var location in locations) { cbLocations.Items.Add(location); } cbLocations.SelectedIndex = 0; cbLocations.Show(); } else { cbLocations.Hide(); } } // Update storageaccounts var storageaccounts = storageaccountsTask.Result; cbPackageStorage.Items.Clear(); foreach (var storageAccount in storageaccounts.OrderBy(storageAccount => storageAccount.Name)) { if (ShouldFilter(locationFilter, storageAccount.Properties.Location, storageAccount.ExtendedProperties)) { continue; } cbPackageStorage.Items.Add(storageAccount); } cbPackageStorage.ValueMember = "Name"; cbPackageStorage.SelectedIndex = 0; // Load slots cbSlot.Items.Clear(); cbSlot.Items.Add(DeploymentSlot.Production); cbSlot.Items.Add(DeploymentSlot.Staging); cbSlot.SelectedIndex = 0; // Load upgrade preferences cbUpgradePreference.Items.Clear(); cbUpgradePreference.Items.Add(new KeyValuePair <UpgradePreference, string>(UpgradePreference.UpgradeWithUpdateDomains, UpgradePreference.UpgradeWithUpdateDomains.GetDescription())); cbUpgradePreference.Items.Add(new KeyValuePair <UpgradePreference, string>(UpgradePreference.UpgradeSimultaneously, UpgradePreference.UpgradeSimultaneously.GetDescription())); cbUpgradePreference.Items.Add(new KeyValuePair <UpgradePreference, string>(UpgradePreference.DeleteAndCreateDeployment, UpgradePreference.DeleteAndCreateDeployment.GetDescription())); cbUpgradePreference.Items.Add(new KeyValuePair <UpgradePreference, string>(UpgradePreference.DeleteAndCreateDeploymentInitiallyStopped, UpgradePreference.DeleteAndCreateDeploymentInitiallyStopped.GetDescription())); cbUpgradePreference.ValueMember = "Key"; cbUpgradePreference.DisplayMember = "Value"; cbUpgradePreference.SelectedIndex = 0; // Load diagnostics storage cbDiagStorage.Items.Clear(); cbDiagStorage.Items.Add("Extract from .cscfg diag connection string"); foreach (var account in storageaccounts.OrderBy(s => s.Name)) { cbDiagStorage.Items.Add(account); } cbDiagStorage.ValueMember = "Name"; cbDiagStorage.SelectedIndex = 0; UpdateFormState(); }); }
private async void HandleDeployClicked(object sender, EventArgs e) { Logger.Debug("[" + _id + "] " + "HandleDeployClicked"); _parent.ColorTab(_id, null); await PerformWorkAsync(bgwork : null, fgwork : async() => { try { var subscription = cbSubscriptions.SelectedItem as SubscriptionListOperationResponse.Subscription; var service = cbCloudservices.SelectedItem as HostedServiceListResponse.HostedService; var packageStorage = cbPackageStorage.SelectedItem as StorageAccount; var slot = (DeploymentSlot)cbSlot.SelectedItem; var pref = ((KeyValuePair <UpgradePreference, string>)cbUpgradePreference.SelectedItem).Key; var diagstorage = cbDiagStorage.SelectedItem as StorageAccount; lblLabelPreview.Text = GetRenderedLabel(); var deploymentLabel = GetRenderedLabel(); if (Configuration.Instance.AutoDownloadPackageBeforeDeploy && !CheckAndChoosePackageDownloadLocation()) { throw new ApplicationException("A download location for packages must be selected"); } if (subscription == null) { throw new ApplicationException("Subscription must be selected"); } if (service == null) { throw new ApplicationException("Cloudservice must be selected"); } if (packageStorage == null) { throw new ApplicationException("Package storage account must be selected"); } if (_selectedPackage == null) { throw new ApplicationException("A .cspkg file must be selected"); } if (_selectedConfig == null) { throw new ApplicationException("A .cscfg file must be selected"); } if (_selectedDiag == null) { if (MessageBox.Show("Diagnostics configuration is not selected. Are you sure you want to continue?", "Diagnostics Configuration", MessageBoxButtons.YesNo) != DialogResult.Yes) { return; } } if (!File.Exists(_selectedPackage)) { throw new ApplicationException("The specified .cspkg no longer exists on the filesystem: " + _selectedPackage); } if (!File.Exists(_selectedConfig)) { throw new ApplicationException("The specified .cscfg no longer exists on the filesystem:" + _selectedConfig); } if (_selectedDiag != null && !File.Exists(_selectedDiag)) { throw new ApplicationException("The specified diagnostics configuration file no longer exists on the filesystem: " + _selectedDiag); } try { if (Configuration.Instance.AutoDownloadPackageBeforeDeploy) { await AzureHelper.DownloadDeploymentAsync(_id, subscription, service, slot, packageStorage, Configuration.Instance.PackageDownloadPath, true); } await AzureHelper.DeployAsync(_id, subscription, service, packageStorage, slot, pref, _selectedPackage, _selectedConfig, _selectedDiag, diagstorage, deploymentLabel, Configuration.Instance.CleanupUnusedExtensions, cbForceUpgrade.Checked); _parent.ActionCompleted("ACD: " + service.ServiceName + "/" + slot, "Successfully deployed", ToolTipIcon.Info); _parent.ColorTab(_id, Color.LightGreen); } catch (CloudException cex) { Logger.Error("[" + _id + "] " + cex.Message); _parent.ActionCompleted("ACD: " + service.ServiceName + "/" + slot, "Failed deployment", ToolTipIcon.Error); _parent.ColorTab(_id, Color.LightPink); } catch (StorageException sex) { Logger.Error("[" + _id + "] " + sex.Message); _parent.ActionCompleted("ACD: " + service.ServiceName + "/" + slot, "Failed deployment", ToolTipIcon.Error); _parent.ColorTab(_id, Color.LightPink); } } catch (ApplicationException aex) { // We use ApplicationExceptions to indicate a custom error. All other errors will result in a ReportBug dialog. MessageBox.Show(this, "[" + _id + "] " + "Deployment failed: " + aex.Message); } }); }