Wednesday, July 24, 2019

Copy Docker Image from One machine to another

go to the machine that has image. run following command. You need to use repository name and tag.  if you don't use them but use image id, that tag and repository won't carry over to the new image.

docker save microsoft/bcsandbox:us > c:\newd365.tar

Once done, copy the file to the new machine and import it using following command.

docker load -i c:\newd365.tar

It may take a while and then you should get the image.

list the images using
docker image ls -a

and you should see the image. 

Monday, July 15, 2019

Getting and Killing Process running at certain port


Get all the processes running at port using

netstat -ano | findstr :yourPortNumber

and then
kill using pid
taskkill /pid {processid} /f

Sunday, March 31, 2019

Configure Redis in Development Environment


  1. Run this on Command Prompt.(Command Prompt with Admin rights)
@"%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe" -NoProfile -InputFormat None -ExecutionPolicy Bypass -Command "iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))" && SET "PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin"
  1. Now Run “choco install redis-64”
  2. Once this done execute “redis-server”. This will start redis server
and then can access redis cache by using the connection string "localhost:6379,ssl=false"
Helpful links:



For GUI
npm install -g redis-commander
redis-commander

Thursday, March 21, 2019

Analize Angular Bundle Size

Install Analyzer
npm i -D webpack-bundle-analyzer

Run Prod build command with --stats-jso argument. 

This will create stats.json. 

then run analyzer command to analyze the result. 
webpack-bundle-analyzer ./dist/stats.json

If any issue running command then add following to your package.json and run npm run bundle-report.


"bundle-report": "webpack-bundle-analyzer dist/stats.json"

Wednesday, February 27, 2019

.net standard project doesnt copy nuget referenced file to bin

add following tag (CopyLocalLockFileAssemblies) into your project file in order for it to work.

<PropertyGroup>
    <TargetFramework>netstandard2.0</TargetFramework>
    <CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
  </PropertyGroup>

Wednesday, December 26, 2018

Howto convert a PFX to a seperate .key/.crt file

openssl pkcs12 -in [yourfile.pfx] -nocerts -out [keyfile-encrypted.key]
What this command does is extract the private key from the .pfx file. Once entered you need to type in the importpassword of the .pfx file.  This is the password that you used to protect your keypair when you created your .pfx file.  If you cannot remember it anymore you can just throw your .pfx file away, cause you won’t be able to import it again, anywhere!.  Once you entered the import password OpenSSL requests you to type in another password, twice!. This new password will protect your .key file.
Now let’s extract the certificate:
openssl pkcs12 -in [yourfile.pfx] -clcerts -nokeys -out [certificate.crt]
Just press enter and your certificate appears.
Now as I mentioned in the intro of this article you sometimes need to have an unencrypted .key file to import on some devices.  I probably don’t need to mention that you should be carefully. If you store your unencrypted keypair somewhere on an unsafe location anyone can have a go with it and impersonate for instance a website or a person of your company.  So always be extra careful when it comes to private keys! Just throw the unencrypted keyfile away when you’re done with it, saving just the encrypted one.
The command:
openssl rsa -in [keyfile-encrypted.key] -out [keyfile-decrypted.key]
Again you need to enter an import password. This time you need to enter the new password that you created in step 1.  After that you’re done. You decrypted your private key. In the folder you ran OpenSSL from you’ll find the certifcate (.crt) and the two private keys (encrypted and unencrypted).

Ref: https://www.markbrilman.nl/2011/08/howto-convert-a-pfx-to-a-seperate-key-crt-file/
Ref: https://aws.amazon.com/blogs/security/how-to-import-pfx-formatted-certificates-into-aws-certificate-manager-using-openssl/#:~:text=To%20import%20the%20certificates,Select%20Import%20a%20certificate.

Sunday, August 26, 2018

Self Contained ASP.NET Core Deployments

dotnet publish ProjectName.csproj --self-contained:true --runtime:win10-x64 /nologo /p:PublishProfile=Release  /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /maxcpucount:1 /p:platform="Any CPU" /p:configuration="Release" /p:DesktopBuildPackageLocation="$\project.zip"

--runtimeIdentifier: it is necessary. Also, you need to specify the supported runtime identifier in your poject file.
(https://docs.microsoft.com/en-us/dotnet/core/rid-catalog)

Commands
https://docs.microsoft.com/en-us/dotnet/core/tools/dotnet-publish?tabs=netcore21