Monday, May 28, 2018

Git Commands

To revert local check in. 
git reset Head~1

To view the changes recently reset, 
git reflog show HEAD
or 
git reflog.

This will show you your recent resets and other history.
You can restore it again using following command.
git reset --hard <commit hash>

above command will destroy any local modifiction so better stash them.


To merge your development branch into master.  

1. Check out the branch. 

git checkout development

2.Merge your changes from master into development. (This step is necessary so that you can resolve any merge conflict locally in your development branch. )

git merge development

3.  Check out the master branch now. 

git checkout master

4. Merge the development branch into master. (Make sure to use --no-ff to persist your history.)

git merge --no-ff development. 

5. Push your changes to the master. 




Thursday, May 10, 2018

Getting all Users from AAD using Power Shell and Delete

Connect-MsolService
Get-MsolUser
#get the user principle name.
Connect-AzureAD
Remove-AzureADUser -ObjectId "xxxx.onmicrosoft.com#EXT#@yyyy.onmicrosoft.com"

UPN of the external accounts is as shown above. 

Thursday, May 3, 2018

Storing secrets using SecretManager for development in ASP.NET Core

The purpose of using this is to keep the secured values outside of the code to avoid check in by mistake.

- Modify the .csproj file and add following "Microsoft.Extensions.SecretManager.Tools"

- Save and close.
- Right click the project and select "Manage User Secrets"
- this will open JS. store your secret values in there.  This json file is stored away from the project on local machine.
- Add following into your Startup.cs file.

if (_hostingEnvironment.IsDevelopment())
            {
                builder.AddUserSecrets<Startup>();
            }

- read the secret using Configuration. like if the secret name is "MySecret", read it like Configuration["MySecret"]
-This should only be used in development.
- For production, code will read the value from appsettings.json. 

Routing Trace to Console

ConsoleTraceListener listener = new ConsoleTraceListener();
Trace.Listeners.Add(listener);

Trace.WriteLine("Trace Logs");

Trace.Listeners.Remove(listener);

Trace.Close();

Tuesday, April 10, 2018

constructor with parameter in .net core dependency injection

In .net core you register the dependency like

services.AddSingleton<IConfigsService, ConfigsService>();

If ConfigureService is taking parameter there is no way out of the box to pass the parameter value.

So in order to fix that, add the nuget parameter "Microsoft.Extensions.DependencyInjection"

services.AddTransient<IConfigsService>(c => new ConfigsService("Pass your data"));

And that should do it.

Thanks,

Tuesday, March 27, 2018

Delete a key from registry - Permission denied issue

get psexec is available from Microsoft here

And then go to the folder of psexec and run following command. 
psexec -i -d -s c:\windows\regedit.exe

It will open regedit. then set the permisison in there and then you can delete. 


Thursday, March 8, 2018

Flush IIS Logs in Real Time

Use following command to flush IIs Logs in real time without 60 seconds wait.

netsh http flush logbuffer

can run following command in background 

while true; do netsh http flush logbuffer > /dev/null; sleep 1; done &

and then tail
tail -100f u_ex130814.log