private void UploadVhd(TemplateImage image) { UploadScriptResult response = null; Collection <PSObject> scriptResult = null; string command = null; task.SetStatus(Commands_RemoteApp.TemplateImageUploadingStatusMessage); response = CallClient_ThrowOnError(() => Client.TemplateImages.GetUploadScript()); if (response != null && response.Script != null) { string uploadFilePath = string.Concat(Environment.GetEnvironmentVariable("temp"), "\\uploadScript.ps1"); try { File.WriteAllText(uploadFilePath, response.Script); } catch (Exception ex) { task.SetState(JobState.Failed, new Exception(string.Format(Commands_RemoteApp.FailedToWriteToFileErrorFormat, uploadFilePath, ex.Message))); return; } command = String.Format("{0} -Uri \"{1}\" -Sas \"{2}\" -VhdPath \"{3}\"", uploadFilePath, image.Uri, image.Sas, Path); scriptResult = CallPowershell(command); } }
public override void ExecuteCmdlet() { // register the subscription for this service if it has not been before // sebsequent call to register is redundent RegisterSubscriptionWithRdfeForRemoteApp(); switch (DetermineParameterSetName()) { case UploadLocalVhd: { string scriptBlock = "Test-Path -Path " + Path; Collection <bool> pathValid = CallPowershellWithReturnType <bool>(scriptBlock); TemplateImage image = null; if (pathValid[0] == false) { throw new RemoteAppServiceException(Commands_RemoteApp.FailedToValidateVhdPathError, ErrorCategory.ObjectNotFound); } task = new LongRunningTask <NewAzureRemoteAppTemplateImage>(this, "RemoteAppTemplateImageUpload", Commands_RemoteApp.UploadTemplateImageJobDescriptionMessage); task.ProcessJob(() => { image = VerifyPreconditions(); image = StartTemplateUpload(image); UploadVhd(image); task.SetStatus(Commands_RemoteApp.JobCompletionStatusMessage); }); WriteObject(task); break; } case AzureVmUpload: { if (IsFeatureEnabled(EnabledFeatures.goldImageImport)) { ImportTemplateImage(); } else { ErrorRecord er = RemoteAppCollectionErrorState.CreateErrorRecordFromString( string.Format(Commands_RemoteApp.ImportImageFeatureNotEnabledError), String.Empty, Client.Account, ErrorCategory.InvalidOperation ); ThrowTerminatingError(er); } break; } } }
public override void ExecuteCmdlet() { DateTime today = DateTime.Now; CollectionUsageDetailsResult detailsUsage = null; string locale = String.Empty; if (String.IsNullOrWhiteSpace(UsageMonth)) { UsageMonth = today.Month.ToString(); } if (String.IsNullOrWhiteSpace(UsageYear)) { UsageYear = today.Year.ToString(); } locale = System.Globalization.CultureInfo.CurrentCulture.ToString(); detailsUsage = CallClient(() => Client.Collections.GetUsageDetails(CollectionName, UsageYear, UsageMonth, locale), Client.Collections); if (detailsUsage == null) { return; } if (AsJob.IsPresent) { task = new LongRunningTask <GetAzureRemoteAppCollectionUsageDetails>(this, "RemoteAppBackgroundTask", Commands_RemoteApp.UsageDetails); task.ProcessJob(() => { task.SetStatus(Commands_RemoteApp.DownloadingUsageDetails); GetUsageDetails(detailsUsage); task.SetStatus(Commands_RemoteApp.JobComplete); }); WriteObject(task); } else { GetUsageDetails(detailsUsage); } }
public override void ExecuteCmdlet() { if (AsJob.IsPresent) { task = new LongRunningTask <PublishAzureRemoteAppProgram>(this, "RemoteAppBackgroundTask", Commands_RemoteApp.Publish); task.ProcessJob(() => { task.SetStatus(Commands_RemoteApp.Publishing); PublishAction(); task.SetStatus(Commands_RemoteApp.JobComplete); }); WriteObject(task); } else { PublishAction(); } }