Wednesday, June 7, 2023

Call Power BI API from .net Core API with Delegated Permissions

 If you want to consume Power BI API from .net Core API there are multiple ways of doing it. 

1. Call with Delegated Permission. 

2. Call with Service Principle. 

Certain endpoints cannot be called with Service Principle. Like you want to get the list of reports that caller user has access too. In this case, you'll need to use Delegated Permission. 

In order to achieve this in ASP.NET Core API,  you need to do the following 


1. Register an App in Azure. 

2. Go to API Permissions and select the Delegated Permissions for Power BI Service. 

3. In your API, you need to inject the following. 


3. Pay attention to the method "GetAccessTokenForUserAsync" used to get the delegated access and the ClaimPrincipal is passed in the method. 

4. This will give you the token which you can use to call the Power BI API. 




Thursday, May 4, 2023

Some Useful features - Microsot Devleoper World!!

 Here are some of the new and exciting features in Microsoft Dev World.

Some of them are available in preview. 

EF Core Power Tool - To generate DB Context

 Nice tool with a lots of customization to generate the DB Schema. 

EF Core Power Tools 

There are lot of material available on how to get started and it is very straight forward to start using it. 

Best thing I like about this and why I used it to customize the name of the Class which is being generated. If you have multiple table with the same name but in the different schema, by default the class name are appended with 1,2. 

For example,

If you have two tables, 

Local.Customer
Master.Customer

Then default EF core will generate the class name as Customer & Customer1. Not that intuitive. 

With EF Core Power Tools, You can customize the class name generation. 

Create a new file with the name "efpt.renaming.json" and put it inside the same folder as your "efpt.config.json".





    







You can also customize the columns inside a table. 

* If you are renaming multiple tables from a single schema, add all of them in the same Tables array. 

 I would try to create a small video some time and share the link.

Until next Cheers!


 

 


Tuesday, January 25, 2022

Tips for faster angular Development

  • Use Host Module Replacement
    • ng serve --hmr  
  • Open browser automatically
    • ng serve --hmr -o
  • Have multiple terminal Open in VS Code.

Thursday, January 20, 2022

Angular Error - Node Sass does not yet support your current environment: Windows 64-bit with Unsupported runtime

Mostly this happens when there is conflict in the npm version installed vs the version which is your project using.

Best way worked for me is to uninstall node-saas and install saas. 

Commands to follow


1. npm uninstall node-sass

2. npm install sass

Thanks!



Wednesday, September 8, 2021

Administer Port Exclusion

 There might be instances when you cannot use a port. You end up getting the error that port is in use. However, no process using that port. 

That could be because those ports might be reseverd. you can check it using the following command

netsh int ip show excludedportrange protocol=tcp

If you see your port there, you can clear those reservation using the following command

net stop winnat

Tuesday, September 7, 2021

Docker Desktop - Error message when trying to switch to windows container

 Exception:

System.ServiceProcess.TimeoutException:
Time out has expired and the operation has not been completed.
at System.ServiceProcess.ServiceController.WaitForStatus(ServiceControllerStatus desiredStatus, TimeSpan timeout)
at Docker.Backend.Processes.WindowsDockerDaemon.TryToStartService(Settings settings, String args, Dictionary`2 env) in C:\workspaces\master-merge\src\github.com\docker\pinata\win\src\Docker.Backend\Processes\WindowsDockerDaemon.cs:line 208
at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.<>c__DisplayClass6_1.b__0(Object instance, Object[] methodParameters)
at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ExecuteAsync(HttpControllerContext controllerContext, IDictionary`2 arguments, CancellationToken cancellationToken)
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Web.Http.Controllers.ApiControllerActionInvoker.d__1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Web.Http.Controllers.ActionFilterResult.d__5.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Web.Http.Dispatcher.HttpControllerDispatcher.d__15.MoveNext()


Solution:

Remove the readonly flag of the following file. 

C:\ProgramData\Docker\panic.log

Don't know the connection but it works :)