Windows Azure - Installing MSI causes hangup? - asp.net

I have a Windows Azure startup task that I am trying to run for installing an MSI. I am trying to run the task via a powershell script. I can confirm that the powershell script runs when I have the following:
"Before powershell" >> C:\hello.txt
$msi = "E:\approot\bin\StartupScripts\AppInitalization_x64.msi"
if($true -eq [System.IO.File]::Exists($msi))
{
"file exists" >> C:\hello.txt
}
else
{
"file does not exist" >> C:\hello.txt
}
"After powershell" >> C:\hello.txt
If I run a deployment, my hello.txt contains "Before, file exists" and "after".
However if I try to change the file exists condition to be:
$arguments= ' /qn /l*v C:\AppInitalization_x64.txt'
Start-Process `
-file $msi `
-arg $arguments `
-passthru
The deployment hangs (i've let it wait up to five hours).
If I remote into the machine and try that same powershell snippet, it installs just fine.
Any ideas on why it would be hanging when I have this as part of the startup script?

Have you looked at AppInitialization_x64.txt to see where the Windows Installer package is hanging? That should give you a good indication, since you've already enabled verbose logging.

Related

Attaching automation test results to slack message

I am currently running my automation (UI & API) tests on azure devops release pipeline.
Whenever the test run finishes I get a notification to my slack:
Now theres only one way to view the test results after a run:
You can click on the Release hotlink and you will get redirected to the full release run info and test results too
.
Now my question is: is it possible to somehow customize the release notes?
For example Id love to attach Test Results to the slack message. Something along the lines:
TestResults:
Passed: 13
Failed: 2
Or somehow attach the .trx/.html file that gets generated after the test run. So I could easily view the results without clicking on the release hotlink.
Maybe its possible to extract test results using GET Runs List API method?
Any kind of help would be greatly appreciated. Thanks!
You can parse the result file(eg:trx) with a powershell script, get the testrun details, post to slack channel via rest api or PostSlackNotification task.
For example: check the trx file in log:
Add a new powershell script task to parse testrun details:
#get the path of the trx file from the output folder.
$path = Get-ChildItem -Path $(Agent.TempDirectory)\TestResults -Recurse -ErrorAction SilentlyContinue -Filter *.trx | Where-Object { $_.Extension -eq '.trx' }
$appConfigFile = $path.FullName #path to test result trx file
$appConfig = New-Object XML
$appConfig.Load($appConfigFile)
$testsummary = $appConfig.DocumentElement.ResultSummary.Counters | select total, passed, failed, aborted
echo $testsummary # check testsummary
echo "##vso[task.setvariable variable=testSummary]$($testsummary)" #set the testsummary to environment variable
Get the testrun result as below:
Posted to slack channel:
There is an npm package to publish test results back to either microsoft teams or slack.
https://www.npmjs.com/package/test-results-reporter
You need to create an incoming-webhook and a simple config file to get started.
Add the below command in your pipeline yaml file.
- script: npx test-results-reporter publish -c config.json

R beakr script as Rscript Windows 10 service

I'm trying to setup a simple beakr service in Windows that implements the example at https://github.com/MazamaScience/beakr. I'm able to run the script from the command line successfully and I've been able to add the service in Windows using NSSM, but I am unable to start the service.
When I dig into the service error logs I see that Rscript.exe cannot be executed due to a non-specific permissions problem.
My Rscript.exe is running out of C:\Program Files\R<Version>\bin and my beakr.R script is running out of my User home directory.
If anyone has had success implementing a similar service (Web page based REST endpoint) using R in Windows, I would love to know how you did it.
This is what I did to run an R script as Service using latest pre-release version of NSSM on Windows 10:
Create a directory to store the files
In this example : C:\R\ServiceTest
Create in this directory a never ending script : ServiceTest.R
library(beepr)
# Test script : beeps every 10 seconds
while (T) {
beepr::beep(1)
if (interactive()) {
# Shows spin cursor to facilitate test in interactive mode
for (i in 1:10) {
if (i%%4==0) {cursor <- '/'}
if (i%%4==1) {cursor <- '-'}
if (i%%4==2) {cursor <- '\\'}
if (i%%4==3) {cursor <- '|'}
cat('\r',cursor)
flush.console()
Sys.sleep(1)
}
} else {
Sys.sleep(10)
}
}
I used to let this kind of script run in a console open on my desktop to check various alarms regularly.
Create a batch file to run the script : ServiceTest.bat
Rscript ServiceTest.R
Open an Admin console and make sure the batch file runs correctly:
C:\R\ServiceTest>ServiceTest.bat
C:\R\ServiceTest>Rscript ServiceTest.R
|
Cancel the batch (Ctrl+C)
Using the Admin console, install the batch file as service using NSSM :
nssm install
Set Service name : ServiceTest
Set Application path : C:\R\ServiceTest\ServiceTest.bat
Set Working directory : C:\R\ServiceTest\
Set Logon : Windows User + Password
Install Service
Open Windows Services Manager, find ServiceTest and start it : if everything went well, that's it!
If you get an error message, check Windows Event Log / Services : you can find there hints on the cause of the problem. Most common problems I encountered :
error on path
used local user instead of own user account / password to run the service
If you want to remove the service :
nssm remove ServiceTest
This replaced very nicely the many R consoles I left running in the background on my Desktop.
I see no reasons it wouldn't work with a REST endpoint.

msdeploy.exe with runcommand: problem executing commands

I want to use msdeploy to start a batch file on my remote server.
Usage is like
msdeploy.exe -verb:sync -allowUntrusted:true -source:runCommand="c:/scripts/x.bat" -dest:auto,computerName=https://server:8172/msdeploy.axd?site=xxx,userName=xxx,password=xxx,authType=basic
The x.bat is executed on the remote server. One part of the x.bat is to delete a local file - that works. Then I want to kill a process on that remote server via "taskkill /FI "WindowTitle eq X" /f", but I get the message that no tasks are found.
When I run the x.bat on the remote server, the tasks are killed just fine...
I solved my problem by using schstart to schedule a task which runs one minute later the batch file
according to taskkill documentation:
Remarks:
The WINDOWTITLE and STATUS filters are not supported when a remote system is specified.
according to start documentation:
Title: Specifies the title to display in the Command Prompt window title bar.
So this title is for cmd window itself not job.exe

Running command prompt arguments by ASP.Net application

I want to run command prompt arguments using a ASP.Net application. I am using visual studio 2013.
Is it possible?
the followings are the command prompt commands I want to execute using MVC application to create and run a job in jenkins
C:\Users\ .jenkins java -jar C:\Users.jenkins\war\WEB-INF\jenkins- cli.jar -s http://localhost create-job myjob < C:\Users\Desktop\config.xml
C:\Users\ .jenkins java -jar C:\Users.jenkins\war\WEB-INF\jenkins-cli.jar -s http://localhost / build myjob
Just to be sure, you want to run these command line tools on thee webserver, right? Not on the client connecting to the web application.
If the former, it's pretty straightforward, make sure that you IIS application pool is running under a user account that is allowed to execute these tools and use the Process class together with the ProcessStartInfo class to invoke the commandline and wait for the results:
string jobname = jobNameFromInput;
if (!Regex.IsMatch(jobname, "^(\"[a-z0-9-_ ]+\"|'[a-z0-9-_ ]+'|[a-z0-9-_]+)$", RegexOptions.IgnoreCase)
{
throw SecurityException("Invalid job name");
}
ProcessStartInfo startInfo = new ProcessStartInfo("C:\Users.jenkins\java.exe");
string argumentTemplate = "-jar C:\\Users.jenkins\\war\\WEB-INF\\jenkins-cli.jar -s http://localhost / build {0}";
startInfo.Arguments = string.Format(argumentTemplate, jobname);
Process.Start(startInfo);
Process.WaitForExit();
See:
Process.WaitForExit
Process.Start

MSdeploy in Powershell - show or help me something really working

I set up TFS Deployer currenlty at work and have been tried to write a Powershell script for the deployment. I have been researched and read many posted questions and answers at StackoverFlow but I couldn't really making the script working yet.
So far, when I run the following PS on windows PowerShell ISE, it runs.
$envMsDeploy = $env:msdeploy
$DirMsDeploy = split-Path -Parent $envMsDeploy
# defined the current location to $DirMSDeploy = C:\Program Files\IIS\Microsoft Web Deploy V2
set-location $DirMsDeploy
$arg = #(
'-verb:sync';
'-source:contentPath=' + $buildDroppedLocation;
'-dest:contentPath=' + $destinationPath;
' -whatif > c:\temp\msdeploy.log'
)
$runMSDeploy = ($DirMsDeploy + "\Msdeploy.exe " + $arg)
$runMSDeploy | Out-file c:\temp\MsDeployTest.bat
I put the last sentence to confirm what gets saved $runMSDeploy. Now looks like $runMSDeploy saves what I want to put finally.
MSDeployTest.Bat contains C:\Program Files\IIS\Microsoft Web Deploy V2\Msdeploy.exe -verb:sync -source:contentPath=[[c:\source folder]] -dest:contentPath=[[Detination UNC path]] -whatif > c:\temp\msdeploy.log
This is where I'm stuck at right now. Because of the c:\Program files contains the empty folder, cmd doesn't run successfully rather giving me the error, "cmd.exe : 'C:\Program' is not recognized as an internal or external command"
If you have any suggestions or idea, please let me know.
thanks,
wanttogoshreddingeveryday
Here is a small example which start notepad.exe with a parametter
function F([string]$file)
{
notepad.exe $file
}
Clear-Host
F "c:\Temp\fic.txt"
JP
Try this gist. It should have everything you need to deploy via powershell https://gist.github.com/579086
It uses Psake, but it will work without it as well.

Resources