Tuesday, May 31, 2022

The operation is not allowed by RBAC. If role assignments were recently changed, please wait several minutes for role assignments to become effective

  Dear Mates, If you are new to key-vault in azure and you are selected Azure role-based access control for more reference pls click this link, If you are facing an issue creating Secret Key solutions are as below 

"The operation is not allowed by RBAC. If role assignments were recently changed, please wait several minutes for role assignments to become effective"

So as per the above error, it is expected we have to assign the role to the User.

Steps:

  1. Go to your Key vault after its created and then click on Access Control (IAM)


  2. Then click on Add Role assignment and then add Key vault Administrator Role to your name:
         

    3. After you review and assign the role, you will be successfully able to create/manage the objects present inside the Key vault.
 



After completing, this process Go to the Secrets option Problem is solved.


Now you can create new 
the Secrets.

Thank you.








Monday, May 30, 2022

Enable Azure RBAC permissions on Key Vault

 Login in azure  Go to Home.



Select Access policies tab from left .


Check Azure role-based access control



Thank , Happy learning 



Wednesday, May 11, 2022

Enable Cross-Origin Requests (CORS) in ASP.NET Core

Hello, All if you are starting working on the .net core I am 100% you are facing the below error at your local.


The solution is very simple you have to add Code in the StartUp or Program file.

var MyAllowSpecificOrigins = "_myAllowSpecificOrigins";

builder.Services.AddCors(options =>

{

    options.AddPolicy(name: MyAllowSpecificOrigins,

                      policy =>

                      {                 

                          policy

                          .AllowCredentials()

                          .SetIsOriginAllowed((host) => true)

                          .AllowAnyHeader()

                          .AllowAnyMethod();

                      });

});

app.UseCors(MyAllowSpecificOrigins);


We have the above code for UI project and Service(Web api) projects.


Thank you !!!

Tuesday, May 10, 2022

The term 'scaffold-dbcontext' is not recognized as the name of a cmdlet, function, script file, or operable program

 Hello All when you want to execute the scaffold-dbcontext "Data Source=(local);Initial Catalog=MyDb;Integrated Security=True;" Microsoft.EntityFrameworkCore.sqlserver -outputdir Models


Gives this error.

scaffold-dbcontext : The term 'scaffold-dbcontext' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At line:1 char:1

+ scaffold-dbcontext "Data Source=(local);Initial Catalog=MyDB;In ...
+ ~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (scaffold-dbcontext:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException


Solution:- The solution is as below 

For me apparently, it worked once I have also ran in the Package Manager console :


 Install-Package Microsoft.EntityFrameworkCore.Tools 



Thank you.

 

Monday, May 9, 2022

API Gateway Ocelot .Net Core 6 Setup

 

Add json file called ocelot.json in your project and default configuration are as below 

{

  "ReRoutes": [

    {

      "DownStreamPathTemplate": "api/WeatherForecast",

      "DownStreamScheme": "http",

      "DownStreamHostAndPorts": [

        {

          "Host": "localhost",

          "Post": 7020

        }

      ],

      "UpStreamPathTemplate": "/WeatherForecast",

      "UpStreamHttpMethod": [ "GET" ]

    }

  ]

}



Then do configure like this in Program.cs:


using Ocelot.DependencyInjection;
using Ocelot.Middleware;

IConfiguration configuration = new ConfigurationBuilder()
                            .AddJsonFile("ocelot.json")
                            .Build();

var builder = WebApplication.CreateBuilder(args);

builder.Services.AddOcelot(configuration);

var app = builder.Build();

app.UseOcelot();
app.Run();


Hope it helps you.Happy Learning ! 


Thank you