JMESPath starts_with function fails using Azure Cli - azure-powershell

In Microsoft Lab 09 > Exercise 4 > Task 1 > 2 it is instructed to list resource groups running the following command
az group list --query "[?starts_with(name,'az400m10l01-RG')].name" --output tsv
If I do run it, I get the following error
].name was unexpected at this time "C:\Program Files (x86)\Microsoft
SDKs\Azure\CLI2\wbin\..\python.exe" -IBm azure.cli group list --query
[?starts_with(name,'az400m10l01-RG')].name --output tsv
I am not an expert in JMESPath, so, can you tell what is wrong with this expression?

I have just came across this thread here
Filtering with Azure CLI and JMESPath for network vnet peering list
the issue got resolved by separating
)]
by a space
) ]
now the command runs fine in local powershell using azure cli
az group list --query "[?starts_with(name,'test') ].name" --output tsv

Related

How to get Google Chrome version Azure DevOps Command Prompt

How can I use command prompt to get the Chrome version on the vmImage on Azure DevOps pipeline?
Try below script in Command line task:
wmic datafile where name="C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe" get Version /value
Then choose corresponding vmimage you want to run.
You can get the Chrome version in Azure Devops with a Powershell task containing this code:
$chromeVersion = ((Get-Item "C:\Program Files\Google\Chrome\Application\chrome.exe").VersionInfo).ProductVersion

Access denied error using vsts

I'm trying to create a wcf service in a lab using vsts.
I have created a build definition that works using a msbuild task. It then uses robocopy to copy the relevant dlls to a remote directory inside a lab using the Publish Artifacts step.
However, I need the content to be created as a windows service, and started after it has been published. It seems like something is running since I see a created log file about 9 minutes after a successful publish, but i cannot see my service inside the services menu, or in IIS.
When I try to run a bat script (using the run script step) that does an sc create, I get an access denied error even though on the vsts build definition I have given the step permission to modify the environment.
This is the full error:
2018-05-17T13:00:13.7702615Z ##[section]Starting: Run script GloBill/InstallBackEnd.bat
2018-05-17T13:00:13.7705444Z ==============================================================================
2018-05-17T13:00:13.7705561Z Task : Batch Script
2018-05-17T13:00:13.7705655Z Description : Run a windows cmd or bat script and optionally allow it to change the environment
2018-05-17T13:00:13.7705748Z Version : 1.1.3
2018-05-17T13:00:13.7705824Z Author : Microsoft Corporation
2018-05-17T13:00:13.7705924Z Help : [More Information](https://go.microsoft.com/fwlink/?LinkID=613733)
2018-05-17T13:00:13.7706023Z ==============================================================================
2018-05-17T13:00:13.7775377Z ##[command]C:\agent\_work\1\s\GloBill\InstallBackEnd.bat
2018-05-17T13:00:13.8030595Z
2018-05-17T13:00:13.8031049Z C:\agent\_work\1\s>sc create GloBillBackEnd ../Services/GloBill.WS.exe
2018-05-17T13:00:13.8048684Z [SC] OpenSCManager FAILED 5:
2018-05-17T13:00:13.8048781Z
2018-05-17T13:00:13.8048901Z Access is denied.
2018-05-17T13:00:13.8048957Z
2018-05-17T13:00:13.8064609Z ##[error]Process completed with exit code 5.
2018-05-17T13:00:13.8073202Z ##[section]Finishing: Run script GloBill/InstallBackEnd.bat
I'm running out of ideas.
The problem was that I was trying to deploy a release from a hosted agent that resided on another machine.
I had to configure a new agent solely for deploying, then i had to tweak my installation script a little by adding the -executionpolicy bypass command.
Here is the new script:
(%1 is the file path)
Powershell.exe -executionpolicy bypass -File %1 -username Username -password ****** -exepath *exe* -serviceName *svcName*

How do I download one or more files from a stopped Fargate task?

I have an ECS task that runs some test cases. I have it running in Fargate. Yay!
Now I want to download the test results file(s) from the container. I have the task and container IDs handy. I can find the exit code with
aws ecs describe-tasks --cluster Fargate --tasks <my-task-id>
How do I download the log and/or files produced?
It looks like, as of right now, the only way to get test results off of my server is to send the results to S3 before the container shuts down.
From this thread, there's no way to mount a volume / EFS onto a Fargate container.
Here's my bash script for running my tests (in build.sh) and then uploading the results to S3:
#!/bin/bash
echo Running tests...
pushd ~circleci/project/
export AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY
export AWS_SECRET_ACCESS_KEY=$AWS_SECRET_KEY
commandToRun="~/project/.circleci/build_scripts/build.sh";
# Run the command
eval $commandToRun 2>&1 | tee /tmp/build.log
# Get the exit code
exitCode=$?
aws s3 cp /tmp/build-$FEATURE.log s3://$CICD_BUCKET/build.log \
--storage-class REDUCED_REDUNDANCY \
--region us-east-1
exit ${exitCode}
Of course, you'll have to pass in the AWS_ACCESS_KEY, AWS_SECRET_KEY and CICD_BUCKET environment variables. The bucket name you choose needs to be pre-created, but any directory structure below it does NOT need to be created in advance.
You probably want to look at using CodeBuild for this use case, which can automatically copy artifacts to S3.
It's actually quite easy to orchestrate the following using a simple bash script and the AWS CLI:
Idempotently Create/Update a CodeBuild project (using a simple CloudFormation template you can define in your source repository)
Run a Codebuild job that executes a given revision of your source repository (using again a self-defining buildspec.yml specification defined in your source repository)
Attach to the CloudWatch logs log group for your CodeBuild job and stream log output
Finally detect when the job has completed successfully or not and then download any artifacts locally using S3
I use this approach to run builds in CodeBuild, with Bamboo as the overarching continuous delivery system.

Execute External commands Fitnesse/DBFit from within a Test page

I would like to execute external commands in my test from Fitnesse/DBFit from within a Test page.
For example, as part of a Unit Test:
run a remote ssh command towards host ABC and copy a file with win cp command
run a DB2 load command to import the data in the database from the file
run a stored procedure
verify results
May anyone advice regarding step 1) ?
There's been a few implementations of a CommandLineFixture - google commandlinefixture and you'll find them.

EMR How to join files into one?

I've splitted big binary file to (2Gb) chunks and uploaded it to Amazon S3.
Now I want to join it back to one file and process with my custom
I've tried to run
elastic-mapreduce -j $JOBID -ssh \
"hadoop dfs -cat s3n://bucket/dir/in/* > s3n://bucket/dir/outfile"
but it failed due to -cat output data to my local terminal - it does not work remotely...
How I can do this?
P.S. I've tried to run cat as a streaming MR job:
den#aws:~$ elastic-mapreduce --create --stream --input s3n://bucket/dir/in \
--output s3n://bucket/dir/out --mapper /bin/cat --reducer NONE
this job was finished successfully. But. I had 3 file parts in dir/in - now I have 6 parts in /dir/out
part-0000
part-0001
part-0002
part-0003
part-0004
part-0005
And file _SUCCESS ofcource which is not part of my output...
So. How to join splitted before file?
So. I've found a solution. Maybe not better - but it is working.
So. I've created an EMR job flow with bootstrap action
--bootstrap-action joinfiles.sh
in that joinfiles.sh I'm downloading my file pieces from S3 using wget, join them using regular cat a b c > abc.
After that I've added a s3distcp which copied result back to S3. ( sample could be found at: https://stackoverflow.com/a/12302277/658346 ).
That is all.