private async Task InitializeARMVMSizes() { AzureContext azureContext = this.AzureSubscription.AzureTenant.AzureContext; azureContext.LogProvider.WriteLog("InitializeARMVMSizes", "Start - Location : " + this.Name); ProviderResourceType provideResourceType = this.AzureSubscription.GetProviderResourceType(ArmConst.MicrosoftCompute, "locations/vmSizes"); if (provideResourceType == null) { azureContext.LogProvider.WriteLog("InitializeARMVMSizes", "Unable to locate Provider Resource Type - Provider : '" + ArmConst.MicrosoftCompute + "' Resource Type: '" + "locations/vmSizes" + "'"); } else if (!provideResourceType.IsLocationSupported(this)) { azureContext.LogProvider.WriteLog("InitializeARMVMSizes", "Provider Resource Type not supported in Location. - Provider : '" + ArmConst.MicrosoftCompute + "' Resource Type: '" + "locations/vmSizes" + "' Location: '" + this.ToString() + "'"); } else { if (_ArmVmSizes == null) { try { AuthenticationResult armToken = await azureContext.TokenProvider.GetToken(this.AzureSubscription.TokenResourceUrl, this.AzureSubscription.AzureTenant.TenantId); // https://docs.microsoft.com/en-us/rest/api/compute/virtualmachines/virtualmachines-list-sizes-region string url = this.AzureSubscription.ApiUrl + "subscriptions/" + this.AzureSubscription.SubscriptionId + String.Format(ArmConst.ProviderVMSizes, this.Name) + "?api-version=" + this.AzureSubscription.GetProviderMaxApiVersion(ArmConst.MicrosoftCompute, "locations/vmSizes"); azureContext.StatusProvider.UpdateStatus("BUSY: Getting ARM VMSizes Location : " + this.ToString()); AzureRestRequest azureRestRequest = new AzureRestRequest(url, armToken); AzureRestResponse azureRestResponse = await azureContext.AzureRetriever.GetAzureRestResponse(azureRestRequest); JObject locationsVMSizesJson = JObject.Parse(azureRestResponse.Response); azureContext.StatusProvider.UpdateStatus("BUSY: Loading VMSizes for Location: " + this.ToString()); var VMSizes = from VMSize in locationsVMSizesJson["value"] select VMSize; List <VMSize> vmSizes = new List <VMSize>(); foreach (var VMSize in VMSizes) { Arm.VMSize armVMSize = new Arm.VMSize(VMSize); vmSizes.Add(armVMSize); azureContext.StatusProvider.UpdateStatus("BUSY: Instantiated VMSize '" + armVMSize.ToString() + "' for Location: " + this.ToString()); } _ArmVmSizes = vmSizes.OrderBy(a => a.Name).ToList(); } catch (Exception exc) { azureContext.LogProvider.WriteLog("InitializeARMVMSizes", "Error loading VM Sizes - Location : " + this.Name + " Error: " + exc.Message); _ArmVmSizes = new List <VMSize>(); } } } azureContext.LogProvider.WriteLog("InitializeARMVMSizes", "End - Location : " + this.Name); azureContext.StatusProvider.UpdateStatus("Ready"); }
private void cbRoleSizes_SelectedIndexChanged(object sender, EventArgs e) { if (cbRoleSizes.SelectedItem != null) { Arm.VMSize selectedSize = (Arm.VMSize)cbRoleSizes.SelectedItem; lblTargetNumberOfCores.Text = selectedSize.NumberOfCores.ToString(); lblTargetMemoryInGb.Text = ((double)selectedSize.memoryInMB / 1024).ToString(); lblTargetMaxDataDisks.Text = selectedSize.maxDataDiskCount.ToString(); _VirtualMachine.TargetSize = selectedSize; } else { _VirtualMachine.TargetSize = null; } PropertyChanged(); }