Skip to content

Instantly share code, notes, and snippets.

View goyalmohit's full-sized avatar

mohit goyal goyalmohit

View GitHub Profile
@goyalmohit
goyalmohit / Show-NestedLoopProgress.ps1
Created February 8, 2019 22:30
Displays progress for nested loop operations in PowerShell using Write-Progress Cmdlet
$outerLoopMax = 255
$innerLoopMax = 126
for ($outerCounter=1; $outerCounter -lt $outerLoopMax; $outerCounter++) {
Write-Progress -Activity "Main loop progress:" `
-PercentComplete ([int](100 * $outerCounter / $outerLoopMax)) `
-CurrentOperation ("Completed {0}%" -f ([int](100 * $outerCounter / $outerLoopMax))) `
-Status ("Outer loop working on item [{0}]" -f $outerCounter) `
-Id 1
@goyalmohit
goyalmohit / dotnet-core-k8s-config.yml
Created January 6, 2019 21:53
Kubernetes configuration for running Sample .NET Core application
apiVersion: v1
kind: Service
metadata:
name: dotnetcore
labels:
app: dotnetcore
spec:
type: ClusterIP
ports:
- port: 80
@goyalmohit
goyalmohit / k8s-vsts-container.yml
Created January 6, 2019 21:35
Configure file to run VSTS agent on kubernetes cluster
apiVersion: v1
kind: ReplicationController
metadata:
name: vsts-agent
spec:
replicas: 1
template:
metadata:
labels:
app: vsts-agent
@goyalmohit
goyalmohit / run-vsts-agent-as-docker-container
Created December 23, 2018 19:58
Contains docker command to run vsts agent as docker container to build docker images for source code
docker run \
-e VSTS_ACCOUNT=<youraccountname> \
-e VSTS_TOKEN=<your-account-Private-access-token> \
-e VSTS_AGENT='$(hostname)-agent' \
-e VSTS_POOL=dockerized-vsts-agents \
-e VSTS_WORK='/var/vsts/$VSTS_AGENT' \
-v /var/run/docker.sock:/var/run/docker.sock \
-v /var/vsts:/var/vsts \
-d microsoft/vsts-agent:<docker-image-name>
@goyalmohit
goyalmohit / azure-pipeline.yml
Created December 23, 2018 19:38
build docker image for dotnet core app and pushes to docker registry
# Build Docker image for this app using Azure Pipelines
pool:
name: 'dockerized-vsts-agents'
variables:
buildConfiguration: 'Release'
imageName: 'dotnetcore:$(Build.BuildId)'
steps:
@goyalmohit
goyalmohit / dotnetcore-convert-code-coverage-files.ps1
Created October 10, 2018 20:00
Convert .coverage files to .coveragexml files for .NET Core Code coverage
Get-ChildItem -Recurse -Filter "*.coverage" | % {
$outfile = "$([System.IO.Path]::GetFileNameWithoutExtension($_.FullName)).coveragexml"
$output = [System.IO.Path]::Combine([System.IO.Path]::GetDirectoryName($_.FullName), $outfile)
"Analyse '$($_.Name)' with output '$outfile'..."
. $env:USERPROFILE\.nuget\packages\microsoft.codecoverage\15.8.0\build\netstandard1.0\CodeCoverage\CodeCoverage.exe analyze /output:$output $_.FullName
}
"Done"
@goyalmohit
goyalmohit / certificate.json
Created September 23, 2018 09:41
Example of certificate.json
{
"certificateSettings": {
"fileName": "my_web_domain.pfx",
"password": "YourSecurePassword"
}
}
@goyalmohit
goyalmohit / import-certificate-in-docker-image
Created September 23, 2018 09:32
Copies SSL Certificate inside Docker Image
...
FROM microsoft/dotnet:2.1-aspnetcore-runtime
WORKDIR /app
COPY --from=build /app .
COPY my_web_domain.pfx .
...
@goyalmohit
goyalmohit / generate-ssl-certificate.ps1
Created September 23, 2018 09:25
Generates Self Signed SSL Certificate
# Generates Certificate and import it to Current user's certificate Store
$certificate = New-SelfSignedCertificate `
-Subject my_web_domain`
-DnsName my_web_domain `
-KeyAlgorithm RSA `
-KeyLength 2048 `
-NotBefore (Get-Date) `
-NotAfter (Get-Date).AddYears(1) `
-CertStoreLocation "cert:CurrentUser\My" `
-FriendlyName "Localhost Certificate for .NET Core" `
@goyalmohit
goyalmohit / maps-krestel-with-ssl-certificate-2
Created September 23, 2018 09:24
Docker Compose sample for mapping krestel with SSL Certificate
...
ports:
- 5000:80
- 5001:443
environment:
ASPNETCORE_URLS: "https://+;http://+"
ASPNETCORE_Kestrel__Certificates__Default__Password: "YourSecurePassword"
ASPNETCORE_Kestrel__Certificates__Default__Path: "my_web_domain.pfx"
...