1

I am trying to have a single sign-in web app through azure that has an initial Microsoft login and then no second login. At the moment I am just trying to get 2 logins to work but when running locally I can get the app to work and show the Power BI reports using a dual login. But whenever I publish the app up to the Azure host and I try to access the power BI page instead of having a Microsoft popup to log in it just suffers from this error.

    [COMException (0x80004005): Error HRESULT E_FAIL has been returned from a call to a COM component.]
   Microsoft.IdentityModel.Clients.ActiveDirectory.AuthenticationContext.RunAsyncTask(Task`1 task) +89
   MultiTenantWebApp.Controllers.PowerBiController.Autenticate() in C:\Users\G4Fro\Source\Repos\Intern\MultiTenantWebApp\MultiTenantWebApp\Controllers\PowerBiController.cs:165
   MultiTenantWebApp.Controllers.PowerBiController.MakeGroupDictionary() in C:\Users\G4Fro\Source\Repos\Intern\MultiTenantWebApp\MultiTenantWebApp\Controllers\PowerBiController.cs:64
   MultiTenantWebApp.Controllers.PowerBiController.EmbedReport() in C:\Users\G4Fro\Source\Repos\Intern\MultiTenantWebApp\MultiTenantWebApp\Controllers\PowerBiController.cs:32
   lambda_method(Closure , ControllerBase , Object[] ) +62
   System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller, Object[] parameters) +14
   System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters) +169
   System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters) +27
   System.Web.Mvc.Async.AsyncControllerActionInvoker.<BeginInvokeSynchronousActionMethod>b__39(IAsyncResult asyncResult, ActionInvocation innerInvokeState) +22
   System.Web.Mvc.Async.WrappedAsyncResult`2.CallEndDelegate(IAsyncResult asyncResult) +29
   System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +49
   System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethod(IAsyncResult asyncResult) +32
   System.Web.Mvc.Async.AsyncInvocationWithFilters.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3d() +50
   System.Web.Mvc.Async.<>c__DisplayClass46.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3f() +228
   System.Web.Mvc.Async.<>c__DisplayClass33.<BeginInvokeActionMethodWithFilters>b__32(IAsyncResult asyncResult) +10
   System.Web.Mvc.Async.WrappedAsyncResult`1.CallEndDelegate(IAsyncResult asyncResult) +10
   System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +49
   System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethodWithFilters(IAsyncResult asyncResult) +34
   System.Web.Mvc.Async.<>c__DisplayClass2b.<BeginInvokeAction>b__1c() +26
   System.Web.Mvc.Async.<>c__DisplayClass21.<BeginInvokeAction>b__1e(IAsyncResult asyncResult) +100
   System.Web.Mvc.Async.WrappedAsyncResult`1.CallEndDelegate(IAsyncResult asyncResult) +10
   System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +49
   System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeAction(IAsyncResult asyncResult) +27
   System.Web.Mvc.Controller.<BeginExecuteCore>b__1d(IAsyncResult asyncResult, ExecuteCoreState innerState) +13
   System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +29
   System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +49
   System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) +36
   System.Web.Mvc.Controller.<BeginExecute>b__15(IAsyncResult asyncResult, Controller controller) +12
   System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +22
   System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +49
   System.Web.Mvc.Controller.EndExecute(IAsyncResult asyncResult) +26
   System.Web.Mvc.Controller.System.Web.Mvc.Async.IAsyncController.EndExecute(IAsyncResult asyncResult) +10
   System.Web.Mvc.MvcHandler.<BeginProcessRequest>b__5(IAsyncResult asyncResult, ProcessRequestState innerState) +21
   System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +29
   System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +49
   System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +28
   System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result) +9
   System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +577
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +157

Any help would be greatly appreciated as I have no idea why it works offline but not online and I don't know how to understand the stack trace

This is the Authentication code

private void Authenticate()
        {
            string clientID = ""; // We have our client ID here that was created in power BI dev apps
            string redirectUri = "https://localhost:44367/";
            string resourceUri = "https://analysis.windows.net/powerbi/api";
            string authorityUri = "https://login.windows.net/common/oauth2/authorize";

            if (token == null)
            {
                AuthenticationContext authContext = new AuthenticationContext(authorityUri);
                token = authContext.AcquireToken(resourceUri, clientID, new Uri(redirectUri)).AccessToken;
            }
            else
            {
                return;
            }
        }
1seanr
  • 657
  • 2
  • 7
  • 18

2 Answers2

2

HRESULT E_FAIL has been returned from a call to a COM component.

have no idea why it works offline but not online and I don't know how to understand the stack trace

According to the exception, it seems that you application try to access to out-of-process COM in the WebApp, but it is restricted in the Web App sandbox.

If it is restricted in the WebApp and Cloudservice is possible, please have try to use Cloudservice. About how to Migrate and Publish a Web Application to an Azure Cloud Service from Visual Studio, we could refer to this document.

Community
  • 1
  • 1
Tom Sun - MSFT
  • 24,161
  • 3
  • 30
  • 47
  • Yea from that link says it seems like it would be restricted but I don't know how to figure out if it is and our current azure subscription doesn't have cloud services so we might need to upgrade that then – 1seanr Oct 25 '17 at 02:38
  • `I don't know how to figure out if it is`. We can't do that with WebApp, it is not allowed us to do that. CloudService may be a choice. – Tom Sun - MSFT Oct 25 '17 at 03:10
0

I am getting this error at the moment and I am pretty sure it has to do with the fact that my azure app does not have the "Access the directory as the signed-in user" permission, since I am accessing Power BI as a master user as in the" App owns data" scenario.

enter image description here

Notes:

  • I only get this error when I unwind the aggregate exception. Otherwise the error message is "One or more errors occurred." Here is a good link on that: Flattening of Aggregate Exceptions
  • It looks like I have the permission, and that I have the rights to grant it, but when I click on the Grant permissions icon I get an error message saying I cannot grant that permission myself.
  • In fact the Azure documentation is clear here that you can grant that permission yourself only for Application Type:Native App, not Web app/API which is what I have here (so the UI has a display bug). Here is a link to it:Permission Scope Docs
  • I am still trying to figure out who my "Admin" is so that I can get this permission, so I am not yet sure that this is the whole issue. Will update.
Community
  • 1
  • 1
Mike Wise
  • 22,131
  • 8
  • 81
  • 104