Share Authetication/Authorization between multitenant Azure Web App and Web Job

44 Views Asked by At

I've developed a single tenant C# Console Web Job to read emails using Graph client from my tenant. I registered an application on Azure and granted it the necessary application permissions.

In my Web Job I do the following:

      var tenantId = "XXXXXXXXX";  
      var clientId = "YYYYYYYYY";  // application object ID
      var clientSecret = "ZZZZZZZZZZZZZZ"; // application secret
      var scopes = new[] { "https://graph.microsoft.com/.default" };

      var options = new TokenCredentialOptions
      {
          AuthorityHost = AzureAuthorityHosts.AzurePublicCloud
      };

      var clientSecretCredential = new ClientSecretCredential(tenantId, clientId, clientSecret, options);
      var graphClient = new GraphServiceClient(clientSecretCredential, scopes);

Actually I should develop a multitenant Web App to login a user of any tenant and async call the web job to execute in the tenant of the user without waiting for the web job to end. I registered a multitenant app on the Azure portal but now my problem is: how do I login the user in the Web App and share the granted delegated permissions to run the Web Job (obviously changing the code above) ?

0

There are 0 best solutions below