How to debug sharepoint 2013 provider hosted app?

We developed SharePoint 2013 provider hosted app using MVC 5 Entity Framework of Database first and publish in Windows Azure site as well as deployed that project to our SharePoint app Catalog. We need to change Windows azure site so we
changed to publish in  another Windows Azure site and deployed again to our SharePoint app Catalog. No problem the app is working after we changed Windows Azure site. I am new of this technology I faced so hard of changed
existing Windows Azure site to New Windows Azure site. Please tell me how to debug the SharePoint Provider hosted app? Please tell me step by step process.
 Thanks in Advance.

Hi,
According to your description, you might want to know how to debug provider hosted app.
To get a quick start, I would suggest you take a look at the link below about
Debugging SharePoint Apps That Are Hosted In Windows Azure Web Sites:
http://blogs.technet.com/b/speschka/archive/2013/11/25/debugging-sharepoint-apps-that-are-hosted-in-windows-azure-web-sites.aspx
Another two similar articles for your reference:
http://sharepointfieldnotes.blogspot.jp/2013/03/making-it-easy-to-develop-and-debug.html
http://blogs.msdn.com/b/officeapps/archive/2013/01/03/debugging-remote-event-receivers-with-visual-studio.aspx
Best regards,
Patrick
Patrick Liang
TechNet Community Support

Similar Messages

  • SharePoint 2013 Provider hosted App installation error

    Hi All,
    I am trying to install a provider hosted app in SharePoint 2013. Installation goes for about 15mins and get "Sorry, something went wrong
    with adding the app. Click to retry."
    Please find belw ULS details for Correlation ID:
    Error when try to get access token when deploy AppInstanceId 7bcf1d9d-897a-48a1-b4f4-cd3120fd98a5 with AppPrincipalId i:0i.t|ms.sp.ext|[email protected]01b993b6. Exception=System.InvalidOperationException:
    An unexpected error was returned from the delegation service.  Error Code: 'invalid_client' Error Description: 'ACS65003: The clientId 'd12de581-316c-4224-b58b-e91ac2042150/www.SERVERNAME.DOMAIN.com@0d85160c-5899-44ca-acc8-db1501b993b6' is not a valid
    service identity.  Trace ID: 4a0c4974-94f4-4077-9a22-2ba5f0abb444  Correlation ID: 674d9839-686b-45f3-be46-31db4dc2a9d0  Timestamp: 2014-07-23 09:34:49Z'    
     at Microsoft.SharePoint.Administration.SPAzureAccessControlDelegationServiceClient.HandleUnexpectedError(SPAzureAccessControlDelegationServiceResponse delegationServiceResponse)    
     at Microsoft.SharePoint.ApplicationServices.SPApplicationContextAccessToken.GetResponseOrThrow[T](SPAzureAccessControlDelegationServiceClient delegationServiceClient, SPAzureAccessControlDelegationServiceResponse delegationServiceResponse)    
     at Microsoft.SharePoint.ApplicationServices.SPApplicationContextAccessToken.IssueApplicationContextAccessToken(SPServiceContext serviceContext, SPApplicationContextAccessTokenCreationParameters creationParameters)    
     at Microsoft.SharePoint.SPSecurityContext.SecurityTokenForApplicationContext(SPIdentityContext userIdentityContext, String applicationId, Uri applicationRealm, SPApplicationContextAccessTokenType applicationTokenType, SPApplicationDelegationConsentType
    consentValue)    
     at Microsoft.SharePoint.SPServerToAppServerAccessTokenManager.GetAccessTokenForDeploymentTask(Guid siteId, SPUserToken userToken, String appPrincipalId)    
     at Microsoft.SharePoint.Lifecycle.SPAppPrincipalAccessTokenTask.<>c__DisplayClass1.<Deploy>b__0()
    sudesh withanage

    Hi  sudesh,
    According to your description, my understanding is that you encountered the error “An unexpected error was returned from the delegation service" when you try to add a SharePoint 2013 Provider hosted App.
    As the error message says, the clientId 'd12de581-316c-4224-b58b-e91ac2042150/www.SERVERNAME.DOMAIN.com@0d85160c-5899-44ca-acc8-db1501b993b6' is not a valid service identity when your SharePoint  try
    to get access token via ACS. Is there any plans to develop a low trust mechanism for non-connected scenarios? i.e. low trust provider hosted apps with no external connection, like say for a Bank who lock down external access.  Please  follow the
    steps as the blog  to set development environment for  SharePoint Low-Trust Apps:
    http://blogs.msdn.com/b/besidethepoint/archive/2012/12/10/sharepoint-low-trust-apps-for-on-premises-deployments.aspx?PageIndex=1#comments
    Best Regards,
    Eric
    Eric Tao
    TechNet Community Support

  • Report Viewer control in sharepoint 2013 provider hosted app

    sharepointSite/_vti_bin/ReportServer
    We are migrating sp 2010 site to SP 2013 provider hosted app. we are using Report viewer control (version 10.0.0) in .net application app server, And the reporting service is configured in sharepoint site and report is uploaded in the document
    library. We are using claims based authentication
    ReportViewer1.ServerReport.ReportServerUrl =
    newUri("sharepointSite/_vti_bin/ReportServer");
    ReportViewer1.ServerReport.ReportPath = @"sharepointSite/_vti_bin/ReportServer?sharepointSite/Reports/Report1.rdl";
    and am getting an error
    ReportServerException: For more information about this error navigate to the report server on the local server machine, or enable remote errors]
    [ReportServerException: The user does not exist or is not unique.]
    [ReportServerException: Report Server has encountered a SharePoint error. (rsSharePointError)]
       Microsoft.Reporting.WebForms.ServerReportSoapProxy.OnSoapException(SoapException e) +82
       Microsoft.Reporting.WebForms.Internal.Soap.ReportingServices2005.Execution.ProxyMethodInvocation.Execute(RSExecutionConnection connection, ProxyMethod`1 initialMethod,
    ProxyMethod`1 retryMethod) +770
       Microsoft.Reporting.WebForms.ServerReport.EnsureExecutionSession() +105
       Microsoft.Reporting.WebForms.ServerReport.SetParameters(IEnumerable`1 parameters) +163
       BP.SDC.eXPP.UIAppsWeb.UserControls.Baseline.ProgressDashboard.RefreshDashboardReport(Int32 userRoadMapDisciplineId, String roadmapSection)
    System.Web.UI.Page.ProcessRequestMain(Boolean
    includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3804
    Can you please help me to solve this issue

    Hi,
    According to your post, my understanding is that you had issues about the provider hosted app.
    Per the error, the issue may be related to the permission issue.
    For a better troubleshooting, we can check with the following steps.
    To norrow down the issue, please create a new and clean app to test whether it has the same issue.
    You can check the ULS log to see if anything unexpected occurred when you deploy the app and open the site page.
    For SharePoint 2013, by default, ULS log is at
    C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\15\LOGS
    You can check the ULS log by the methods here:
    http://blogs.msdn.com/b/opal/archive/2009/12/22/uls-viewer-for-sharepoint-2010-troubleshooting.aspx
    http://msdn.microsoft.com/en-us/library/gg193966(v=office.14).aspx
    Thanks,
    Jason
    Forum Support
    Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact
    [email protected]
    Jason Guo
    TechNet Community Support

  • SharePoint 2013 Provider-Hosted App Installs, throws File Exists error.

    I have a SP2013 Provider-hosted app with DevExpress controls that was working fine until just recently. I am getting the following error when I try to F5 DEBUG:
    "Error occurred in deployment step 'Install app for SharePoint': The file exists."
    The app actually installs and executes but the debugger detaches very quickly plus it is prompting with the nagging aforementioned message. There are no AppUninstall / AppInstall / AppUpgraded events being handled.
    Thanks in advance.

    I tried retraction, cleaning, reinstalling - nothing worked. I tried a new app in the site collection and a new app in a new site collection - still no luck. In the end the problem was more simple, but the "File exists" error was not helpful in determining
    the root cause. Perhaps others will hit this thread and find the solution helpful. Visual Studio will typically switch automatically to "Run as Administrator" mode whenever debugging a SP App for 2013. In my case, it wasn't. I had one or two existing Apps
    that never prompted me but ran fine and in this case, new apps weren't automatically running as the Administrator. After changing this behavior the app (and new apps) work as expected.

  • Retrieve data from a list in SharePoint 2013 provider hosted App using CSOM

    I have developed a provider hosted app in SharePoint 2013. As you already know, Visual Studio creates web application and SharePoint app. The web application gets hosted inside IIS and the SharePoint App in SharePoint site collection. I'm trying to get
    data from a list hosted in SharePoint using CSOM. But I get ran insecure content error. 
    here is my code in Default.aspx
        <script type="text/javascript" src="../Scripts/jquery-1.8.2.js"></script>
        <script type="text/javascript" src="../Scripts/MicrosoftAjax.js"></script>
        <script type="text/javascript" src="../Scripts/SP.Core.js"></script>
        <script type="text/javascript" src="../Scripts/INIT.JS"></script>
        <script type="text/javascript" src="../Scripts/SP.Runtime.js"></script>
        <script type="text/javascript" src="../Scripts/SP.js"></script>
        <script type="text/javascript" src="../Scripts/SP.RequestExecutor.js"></script>
        <script type="text/javascript" src="../Scripts/App.js"></script>
        <html xmlns="http://www.w3.org/1999/xhtml">
        <head runat="server">
            <title></title>
        </head>
        <body>
            <form id="form1" runat="server">
            <div>
                <input id="Button1" type="button" value="Get title via CSOM" onclick="execCSOMTitleRequest()" /> <br />
                <input id="Button2" type="button" value="Get Lists via CSOM" onclick="execCSOMListRequest()" />
            </div>
                <p ID="lblResultTitle"></p><br />
                <p ID="lblResultLists"></p>
            </form>
        </body>
        </html>
    and App.js is:
        var hostwebUrl;
        var appwebUrl;
        // Load the required SharePoint libraries
        $(document).ready(function () {
            //Get the URI decoded URLs.
            hostwebUrl =
                decodeURIComponent(
                    getQueryStringParameter("SPHostUrl")
            appwebUrl =
                decodeURIComponent(
                    getQueryStringParameter("SPAppWebUrl")
            // resources are in URLs in the form:
            // web_url/_layouts/15/resource
            var scriptbase = hostwebUrl + "/_layouts/15/";
            // Load the js files and continue to the successHandler
            //$.getScript(scriptbase + "/MicrosoftAjax.js",
            //   function () {
            //       $.getScript(scriptbase + "SP.Core.js",
            //           function () {
            //               $.getScript(scriptbase + "INIT.JS",
            //                   function () {
            //                       $.getScript(scriptbase + "SP.Runtime.js",
            //                           function () {
            //                               $.getScript(scriptbase + "SP.js",
            //                                   function () { $.getScript(scriptbase + "SP.RequestExecutor.js", execCrossDomainRequest); }
        function execCrossDomainRequest() {
            alert("scripts loaded");
        function getQueryStringParameter(paramToRetrieve) {
            var params = document.URL.split("?")[1].split("&");
            var strParams = "";
            for (var i = 0; i < params.length; i = i + 1) {
                var singleParam = params[i].split("=");
                if (singleParam[0] == paramToRetrieve)
                    return singleParam[1];
        function execCSOMTitleRequest() {
            var context;
            var factory;
            var appContextSite;
            var collList;
            //Get the client context of the AppWebUrl
            context = new SP.ClientContext(appwebUrl);
            //Get the ProxyWebRequestExecutorFactory
            factory = new SP.ProxyWebRequestExecutorFactory(appwebUrl);
            //Assign the factory to the client context.
            context.set_webRequestExecutorFactory(factory);
            //Get the app context of the Host Web using the client context of the Application.
            appContextSite = new SP.AppContextSite(context, hostwebUrl);
            //Get the Web
            this.web = context.get_web();
            //Load Web.
            context.load(this.web);
            context.executeQueryAsync(
                Function.createDelegate(this, successTitleHandlerCSOM),
                Function.createDelegate(this, errorTitleHandlerCSOM)
            //success Title
            function successTitleHandlerCSOM(data) {
                $('#lblResultTitle').html("<b>Via CSOM the title is:</b> " + this.web.get_title());
            //Error Title
            function errorTitleHandlerCSOM(data, errorCode, errorMessage) {
                $('#lblResultLists').html("Could not complete CSOM call: " + errorMessage);
        function execCSOMListRequest() {
            var context;
            var factory;
            var appContextSite;
            var collList;
            //Get the client context of the AppWebUrl
            context = new SP.ClientContext(appwebUrl);
            //Get the ProxyWebRequestExecutorFactory
            factory = new SP.ProxyWebRequestExecutorFactory(appwebUrl);
            //Assign the factory to the client context.
            context.set_webRequestExecutorFactory(factory);
            //Get the app context of the Host Web using the client context of the Application.
            appContextSite = new SP.AppContextSite(context, hostwebUrl);
            //Get the Web
            this.web = context.get_web();
            // Get the Web lists.
            collList = this.web.get_lists();
            //Load Lists.
            context.load(collList);
            context.executeQueryAsync(
                Function.createDelegate(this, successListHandlerCSOM),
                Function.createDelegate(this, errorListHandlerCSOM)
            //Success Lists
            function successListHandlerCSOM() {
                var listEnumerator = collList.getEnumerator();
                $('#lblResultLists').html("<b>Via CSOM the lists are:</b><br/>");
                while (listEnumerator.moveNext()) {
                    var oList = listEnumerator.get_current();
                    $('#lblResultLists').append(oList.get_title() + " (" + oList.get_itemCount() + ")<br/>");
            //Error Lists
            function errorListHandlerCSOM(data, errorCode, errorMessage) {
                $('#lblResultLists').html("Could not complete CSOM Call: " + errorMessage);
    Any solution is appreciated.

    Hi,
    To retrieve data from list in your provider-hosted app using SharePoint Client Object Model(CSOM), you can follow the links below for a quick start:
    http://msdn.microsoft.com/en-us/library/office/fp142381(v=office.15).aspx
    http://blogs.msdn.com/b/steve_fox/archive/2013/02/22/building-your-first-provider-hosted-app-for-sharepoint-part-2.aspx
    Best regards
    Patrick Liang
    TechNet Community Support

  • Getting Client Context in Class Library for Sharepoint 2013 provider hosted app

    I have created an MVC Provider hosted app.
    From my controllers I can easily get the client context via:
    var spContext = SharePointContextProvider.Current.GetSharePointContext(HttpContext);
    But in my layout page, I have a call that gets the topnavbar and replicates it:
    @foreach (var nav in HostHelper.GetNav(this))
    <li class='static'>
    <a class='static menu-item ms-core-listMenu-item ms-displayInline ms-navedit-linkNode' href='@nav.Url'>
    <span class='addition-background ms-navedit flyoutArrow'>
                                                            <span class='menu-item-text'>
    @nav.Title                                                
    </span>                                                   </span>                                               
    </a>                                           
    </li>                                       
    This causes an error because I am not sure how to get the clientcontext from my class. I have tried:
    public static NavigationNodeCollection GetNav()       
    var spContext = SharePointContextProvider.Current.GetSharePointContext(System.Web.HttpContext.Current);
    using (var clientContext = spContext.CreateUserClientContextForSPHost())
    if (clientContext != null)
    NavigationNodeCollection topNav = clientContext.Web.Navigation.TopNavigationBar;            
    clientContext.Load(topNav);                   
    clientContext.ExecuteQuery();                   
    return topNav;                                       }           
    return null;       
    put it doesnt get the client context

    Hi,
    According to your description,  my understanding is that you want to get SharePoint provider hosted app ClientContext in the layout page.
    In the layout page, it needs to use TokenHelper Class to get access token and then retrieve the ClientContext.
    Here is a detailed article for your reference:
    How to Get SharePoint Client Context in SharePoint Apps (Provider Hosted / SharePoint Access ) in CSOM (Client Side Object Model)
    Thanks
    Best Regards
    TechNet Community Support
    Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact
    [email protected]

  • Cryptographic error on a SharePoint 2013 Provider Hosted App

    Below mentioned is the error:
    System.TypeInitializationException: The type initializer for 'ABABABA.TokenHelper' threw an exception. ---> System.Security.Cryptography.CryptographicException: Access denied. at System.Security.Cryptography.CryptographicException.ThrowCryptographicException(Int32
    hr) at System.Security.Cryptography.X509Certificates.X509Utils._LoadCertFromFile(String fileName, IntPtr password, UInt32 dwFlags, Boolean persistKeySet, SafeCertContextHandle& pCertCtx) at System.Security.Cryptography.X509Certificates.X509Certificate.LoadCertificateFromFile(String
    fileName, Object password, X509KeyStorageFlags keyStorageFlags) at System.Security.Cryptography.X509Certificates.X509Certificate2..ctor(String fileName, String password)
    We are pretty sure the App Pool account has access to the file and the path is correct. We have had a dozen number of people who checked these things out.
    Please help out.
    Thanks,
    Aseem Sood

    Hi Aseem,
    Please check the App pool account password and re-enter it once again in advanced settings.
    Whenever you see a reply and if you think is helpful, click "Alternate TextVote As Helpful"! And whenever you see a reply being an answer to the question of the thread, click "Alternate TextMark As Answer

  • How to set another instance of same live app as test app sharepoint 2013 provider hosted

    Hi
    I have SharePoint 2013 provider hosted app published in azure now i need to deploy another instance on same app as separate app for testing purposes, i have created another site in azure and done all profile adding packaging the app with visual studio to
    deploy .App file to SharePoint catalog.  problem is that .app file is same name and when i going to add,  it replace with same version witch deploy as live instance.
    Any one can give solution how to handle this greatly appreciated ...
    Kind Regards
    Radika

    Hi Radika,
    According to your description, there is already an app deployed in your site, you want to deploy another instance of it to the same site for testing purpose.
    As a common practice, when developing an app, for not overriding the previous version, it is recommended to create another project for testing used only with another
    name.
    By doing this, we can keep the development in the testing project, when it is done, migrate the newly customization to the original project and deploy it with a new
    version number.
    Thanks
    Patrick Liang
    Forum Support
    Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support,
    contact [email protected]
    Patrick Liang
    TechNet Community Support

  • Sharepoint online provider-hosted app AppEventReceiver callout failed.

    I've created an AppEventReceiver for sharepoint online provider-hosted app, I can deploy the app if i hosted the remote web application on MS Azure, it work fine. if hosted the remote web application on local machine IIS whith public ip address, when
    I deploy the app online the following error:
    The remote event receiver callout failed.
    Details: There was no endpoint listening at
    http://115.193.xxx.xxx:6666/AppEventReceiver.svc that could accept the message. This is often caused by an incorrect address or SOAP action. See InnerException, if present, for more details.
    two question:
    1. does the provider-hosted app, (remote web application  )must host on Azure so that the AppEventReceiver (appinstalled) then trigger?
    2. what need to do when host on local machine IIS whith public ip address?

    try these link:
    http://www.sharepointnutsandbolts.com/2013/07/deploying-sp2013-provider-hosted.html
    if you are using office365 for sharepoint then you can develope list using sandbox solution .

  • SharePoint remote provider hosted apps - confusion around key questions

    For some time, I have been trying to get a provider hosted app setup to work, and I am afraid that I - as a relative novice - must have missed some key points despite hours of googling and reading. Here's my questions:
    A remote, provider hosted app, would have its AppWeb in a domain that is different from the host SharePoint Farm in which it is gets installed and used. In other words, the AppWeb may be located at remote.contoso-apps.com, where as the SharePoint farm uses
    for instance spslocal.mycorp.com. However, when you - in the SharePoint host farm - set up your App Domain/App isolation - you can only provide one value - which in this case would then need to be remote.contoso-apps.com??? Does that mean that each SharePoint
    Farm can only contain Apps from one vendor delivering remote apps? Or is the key in hard coding the app web in the manifest? (However, even if I've tried this it seems like the token SPAppWebUrl still translates into the pattern defined in the App Isolation
    Settings in the host farm???).
    Back to the AppWeb: Many bloggers have mentioned that you have to add some kind of SharePoint element to your App project (not the Web Project part) to get the AppWeb provisioned from Visual Studio 2013. But at what stage are these SharePoint elements actually
    provisioned - during some kind of publish operation of the Web Project part (the Pages, Scripts etc.) or when you install the app package (hardly the latter, since the first installation may be when a customer installs the app???). The reason I ask is (of
    course) that my SharePoint Elements do not seem to get provisioned. And just to test my very basic understanding: the AppWeb can be any pure IIS web site from the start - i.e., not a SharePoint Web App?
    Thanks for any help on these challenging issues!

    Paul,
    thanks for your effort, but unfortunately the answers do not get me much further.
    Question 1: You write "You can only use one domain, because cross-domain IFrame requests are blocked in SharePoint 2013". This is contrary to numerous other articles that explain how the SharePoint cross-domain library (SP.RequestExecutor.js) can be
    used to communicate across domains. From the outset, the whole idea about an AppWeb is - according to Microsoft documentation - that the AppWeb should be isolated from the HostWeb and therefore in a separate domain. 
    This article,
    http://msdn.microsoft.com/en-us/library/office/jj612823(v=office.15).aspx, even talks about scenarios where the SharePoint Host Web and App Web are in different security zones!
    So according to a load of other documentation it is indeeed a valid scenario I am addressing, but I still miss the key answers to the questions above. I suspect that the key is to hardcode certain URIs in your app that points to the cloud AppWeb
    (so the single App Domain specified in the Host Farm is not used at all), but I have failed to find the necessary documentation on this.
    Question 2: The article mentioned does not talk about the issues that I have asked about, specifically when the SharePoint elements in the App are created.
    Anyone with experience in this area? Thanks!

  • SharePoint Online - Provider hosted App - Deployed in on-premise environment

    Hi
    We are evaluating SharePoint online and wanted to know if the following is possible? If yes, can anyone share his/her experience and issues faced?
    We want to deploy a provider-hosted app to a on-premise environment. This app will need to connect to SharePoint online. What are the requirements from hosting perspective for the on-premise server? Does the server require anything specific so that it is
    able to connect to SPOnline? Should it be outside the corporate firewall?
    What is the difference between SharePoint online standard and dedicated plans, in the context of Provider hosted app. Are there limitations with respect to what can & cannot be done in a Provider hosted app in these environments?
    How do I know if am using a SharePoint online standard or a dedicated plan? Where to look for?
    I have seen few articles where the provider hosted app is deployed to windows azure and is connecting to SharePoint online. However this is not the case with us (i.e. we do not have windows azure for now)
    Regards,
    Deven

    Below links answer most of your questions:
    App- code
    http://msdn.microsoft.com/en-us/library/office/fp142381(v=office.15).aspx 
    How to create high trust apps-  http://msdn.microsoft.com/en-us/library/office/fp179901(v=office.15).aspx
    How to deploy- http://msdn.microsoft.com/en-us/library/office/jj860570(v=office.15).aspx
    Go to billing and subscriptions and you will see what plan you have. Dedicated plans names and options are in this link- http://technet.microsoft.com/en-us/library/dn151715.aspx 
    Regards
    Libin
    Whenever you see a reply and if you think is helpful, click "Vote As Helpful"! And whenever you see a reply being an answer to the question of the thread, click "Mark As Answer Feel free to unmark answer if does not resolves your problem.

  • App Parts (I Frame) is possible in Provider hosted app in SharePoint 2013

    Hi In SharePoint 2013 provider hosted app, is it possible to add App parts
    <WebPartPages:AllowFraming ID="AllowFraming" runat="server" />
    (is I frame) is allowed.
    If possible how to approach, if not what is the solution. Any help will be appreciated

    Hi Ashok,
    Thanks for posting your query, Kindly browse the below mentioned URLs to get the solution for your requirement.
    http://www.codeproject.com/Articles/524232/StepplusbyplusStepplusguideplustopluscreateplusapl
    http://www.sharepointnutsandbolts.com/2012/08/sharepoint-2013-appsarchitecture.html
    http://www.slideshare.net/roykimtoronto/share-point-2013-hosted-app-presentation-roy-kim
    http://blogs.msdn.com/b/richard_dizeregas_blog/archive/2012/08/02/optimizing-user-experience-for-sharepoint-2013-apps.aspx
    I hope this is helpful to you, mark it as Helpful.
    If this works, Please mark it as Answered.
    Regards,
    Dharmendra Singh (MCPD-EA | MCTS)
    Blog : http://sharepoint-community.net/profile/DharmendraSingh

  • SharePoint Provider Hosted App (401) Unauthorized Microsoft.SharePoint.SPException: The Azure Access Control service is unavailable

    Hello,
    I'm attempting to get a SharePoint 2013 Provider Hosted Application working in a brand new SharePoint environment.  I've created snapshots of both my dev and the sharepoint environments along the way and have meticulously documented every step of the
    way.  I've followed these instructions (among many other resources found along this journey) :
    http://msdn.microsoft.com/en-us/library/fp179923(office.15).aspx
    http://technet.microsoft.com/en-us/library/fp161236(office.15).aspx
    http://msdn.microsoft.com/library/office/fp179901%28v=office.15%29
    Upon package and publish of my application to SharePoint, I get a 401 Unauthorized error.  I use Fiddler to obtain the SPErrorCorrelationID to ultimately obtain the following ULS Viewer Output.  Please explain how to fix if you're able.
    Please Note:  I was under the impression that a Provider Hosted Application does not use the Azure Access Control service, so I'm confused as to why my system is attempting to make this connection?
    Also Note:  I've used a self signed and godday obtained certificate to successfully f5 debug my basic web.title (out of the visual studio 2012 box) sharepoint provider hosted application... so I know my certs are good.
    Here's my ULS output:
    03/24/2014 08:54:47.83    w3wp.exe (0x1448)    0x22D8    SharePoint Foundation    Logging Correlation Data    xmnv    Medium    Name=Request (GET:http://portal.cltenet.com/_layouts/15/appredirect.aspx?instance_id=22d5252f%2D392c%2D4f68%2Db820%2Da3053b9d4f24)  
     306c809c-66a1-d0d5-d8e2-89d3631ce1bf
    03/24/2014 08:54:47.83    w3wp.exe (0x1448)    0x22D8    SharePoint Foundation    Authentication Authorization    agb9s    Medium    Non-OAuth request.
    IsAuthenticated=True, UserIdentityName=0#.w|cltenet\sp.apps, ClaimsCount=25    306c809c-66a1-d0d5-d8e2-89d3631ce1bf
    03/24/2014 08:54:47.83    w3wp.exe (0x1448)    0x22D8    SharePoint Foundation    Logging Correlation Data    xmnv    Medium    Site=/    306c809c-66a1-d0d5-d8e2-89d3631ce1bf
    03/24/2014 08:54:47.84    w3wp.exe (0x1448)    0x22D8    SharePoint Foundation    App Deployment    acjjg    Medium    The current user has System.Threading.Thread.CurrentPrincipal.Identity.Name
    = 0#.w|cltenet\sp.apps, System.Security.Principal.WindowsIdentity.GetCurrent().Name = NT AUTHORITY\IUSR, System.Web.HttpContext.Current.User.Identity.Name = 0#.w|cltenet\sp.apps.    306c809c-66a1-d0d5-d8e2-89d3631ce1bf
    03/24/2014 08:54:47.84    w3wp.exe (0x1448)    0x22D8    SharePoint Foundation    App Auth    ajsrv    Medium    redirectLaunUrl after getting it from query
    string, web or app instance: https://hightrust31.cltenetapps.com/Pages/Default.aspx?{StandardTokens}    306c809c-66a1-d0d5-d8e2-89d3631ce1bf
    03/24/2014 08:54:47.85    w3wp.exe (0x1448)    0x22D8    SharePoint Foundation    General    aib0n    High    trying to get app tokens for site: 888b71f7-51ee-40f5-8344-8de4869d37d0
    Unable to load app tokens from appInstanceId: 22d5252f-392c-4f68-b820-a3053b9d4f24    306c809c-66a1-d0d5-d8e2-89d3631ce1bf
    03/24/2014 08:54:47.85    w3wp.exe (0x1448)    0x22D8    SharePoint Foundation    App Auth    ajsrw    Medium    redirectLaunUrl after getting token replacement:
    https://hightrust31.cltenetapps.com/Pages/Default.aspx?SPHostUrl=http%3A%2F%2Fportal%2Ecltenet%2Ecom&SPLanguage=en%2DUS&SPClientTag=0&SPProductNumber=15%2E0%2E4420%2E1017    306c809c-66a1-d0d5-d8e2-89d3631ce1bf
    03/24/2014 08:54:47.85    w3wp.exe (0x1448)    0x22D8    SharePoint Foundation    App Auth    ajsry    Medium    m_oauthAppId after NormalizeAppIdentifier()
    i:0i.t|ms.sp.ext|[email protected]8df36d5d.  Now getting app principal info.    306c809c-66a1-d0d5-d8e2-89d3631ce1bf
    03/24/2014 08:54:47.85    w3wp.exe (0x1448)    0x22D8    SharePoint Foundation    App Auth    ajsr0    Medium    decided that we need to do a POST to the
    app.    306c809c-66a1-d0d5-d8e2-89d3631ce1bf
    03/24/2014 08:54:47.85    w3wp.exe (0x1448)    0x22D8    SharePoint Foundation    App Auth    ajsr1    Medium    m_redirectMessage: EndpointAuthorityMatches  
     306c809c-66a1-d0d5-d8e2-89d3631ce1bf
    03/24/2014 08:54:47.85    w3wp.exe (0x1448)    0x22D8    SharePoint Foundation    App Auth    ajsr2    Medium    realm matched attempting to get app token
    using GetAccessToken()    306c809c-66a1-d0d5-d8e2-89d3631ce1bf
    03/24/2014 08:54:47.85    w3wp.exe (0x1448)    0x22D8    SharePoint Foundation    App Auth    advzm    High    Error when get token for app i:0i.t|ms.sp.ext|[email protected]8df36d5d,
    exception: Microsoft.SharePoint.SPException: The Azure Access Control service is unavailable.     at Microsoft.SharePoint.ApplicationServices.SPApplicationContext.GetApplicationSecurityTokenServicesUri(SPServiceContext serviceContext)    
    at Microsoft.SharePoint.ApplicationServices.SPApplicationContext..ctor(SPServiceContext serviceContext, SPIdentityContext userIdentity, OAuth2EndpointIdentity applicationEndPoint)     at Microsoft.SharePoint.SPSecurityContext.SecurityTokenForApplicationContext(SPIdentityContext
    userIdentityContext, String applicationId, Uri applicationRealm, SPApplicationContextAccessTokenType applicationTokenType, SPApplicationDelegationConsentType consentValue)     at Microsoft.SharePoint.SPServerToAppServerAccessTokenManager.GetAccessTokenPrivate(SPServiceContext
    serviceContext, String appId, Uri appEndpointUrl, SPAppPrincipalInfo appPrincipal, SPApplicationContextAccessTokenType tokenType, Boolean useThreadIdentity, SPUserToken userToken)    306c809c-66a1-d0d5-d8e2-89d3631ce1bf
    03/24/2014 08:54:47.85    w3wp.exe (0x1448)    0x22D8    SharePoint Foundation    App Auth    ajsr3    High    App token requested from appredirect.aspx
    for site: 888b71f7-51ee-40f5-8344-8de4869d37d0 but there was an error in generating it.  This may be a case when we do not need a token or when the app principal was not properly set up.  LaunchUrl:https://hightrust31.cltenetapps.com/Pages/Default.aspx?SPHostUrl=http://portal.cltenet.com&SPLanguage=en-US&SPClientTag=0&SPProductNumber=15.0.4420.1017
    Exception Message:The Azure Access Control service is unavailable.  Stacktrace:    at Microsoft.SharePoint.ApplicationServices.SPApplicationContext.GetApplicationSecurityTokenServicesUri(SPServiceContext serviceContext)    
    at Microsoft.SharePoint.ApplicationServices.SPApplicationContext..ctor(SPServiceContext serviceContext, SPIdentityContext userIdentity, OAuth2EndpointIdentity applicationEndPoint)     at Microsoft.SharePoint.SPSecurityContext.SecurityTokenForApplicationContext(SPIdentityContext
    userIdentityContext, String applicationId, Uri applicationRealm, SPApplicationContextAccessTokenType applicationTokenType, SPApplicationDelegationConsentType consentValue)     at Microsoft.SharePoint.SPServerToAppServerAccessTokenManager.GetAccessTokenPrivate(SPServiceContext
    serviceContext, String appId, Uri appEndpointUrl, SPAppPrincipalInfo appPrincipal, SPApplicationContextAccessTokenType tokenType, Boolean useThreadIdentity, SPUserToken userToken)     at Microsoft.SharePoint.SPServerToAppServerAccessTokenManager.GetAccessTokenFromThreadIdentityOrUserToken(SPServiceContext
    serviceContext, String appId, Uri appEndpointUrl, SPApplicationContextAccessTokenType tokenType, SPAppPrincipalInfo appPrincipal, Boolean useThreadIdentity, SPUserToken userToken)     at Microsoft.SharePoint.ApplicationPages.AppRedirectPage.ValidateAndProcessRequest(). 
    Since this is a nonfatal error, it will be sanitized and posted to the app as part of the app launch.    306c809c-66a1-d0d5-d8e2-89d3631ce1bf
    03/24/2014 08:54:47.85    w3wp.exe (0x1448)    0x22D8    SharePoint Foundation    General    ajlz0    High    Getting Error Message for Exception Microsoft.SharePoint.SPException:
    The Azure Access Control service is unavailable.     at Microsoft.SharePoint.ApplicationServices.SPApplicationContext.GetApplicationSecurityTokenServicesUri(SPServiceContext serviceContext)     at Microsoft.SharePoint.ApplicationServices.SPApplicationContext..ctor(SPServiceContext
    serviceContext, SPIdentityContext userIdentity, OAuth2EndpointIdentity applicationEndPoint)     at Microsoft.SharePoint.SPSecurityContext.SecurityTokenForApplicationContext(SPIdentityContext userIdentityContext, String applicationId, Uri
    applicationRealm, SPApplicationContextAccessTokenType applicationTokenType, SPApplicationDelegationConsentType consentValue)     at Microsoft.SharePoint.SPServerToAppServerAccessTokenManager.GetAccessTokenPrivate(SPServiceContext serviceContext,
    String appId, Uri appEndpointUrl, SPAppPrincipalInfo appPrincipal, SPApplicationContextAccessTokenType tokenType, Boolean useThreadIdentity, SPUserToken userToken)     at Microsoft.SharePoint.SPServerToAppServerAccessTokenManager.GetAccessTokenFromThreadIdentityOrUserToken(SPServiceContext
    serviceContext, String appId, Uri appEndpointUrl, SPApplicationContextAccessTokenType tokenType, SPAppPrincipalInfo appPrincipal, Boolean useThreadIdentity, SPUserToken userToken)     at Microsoft.SharePoint.ApplicationPages.AppRedirectPage.ValidateAndProcessRequest()  
     306c809c-66a1-d0d5-d8e2-89d3631ce1bf
    03/24/2014 08:54:47.85    w3wp.exe (0x1448)    0x22D8    SharePoint Foundation    App Auth    aib0p    Medium    Doing appredirect from appredirect.aspx:
    in site: 888b71f7-51ee-40f5-8344-8de4869d37d0 with RedirectLaunchUrl: https://hightrust31.cltenetapps.com/Pages/Default.aspx?SPHostUrl=http%3A%2F%2Fportal%2Ecltenet%2Ecom&SPLanguage=en%2DUS&SPClientTag=0&SPProductNumber=15%2E0%2E4420%2E1017  
     306c809c-66a1-d0d5-d8e2-89d3631ce1bf
    03/24/2014 08:54:47.85    w3wp.exe (0x1448)    0x22D8    SharePoint Foundation    Monitoring    b4ly    Medium    Leaving Monitored Scope (Request (GET:http://portal.cltenet.com/_layouts/15/appredirect.aspx?instance_id=22d5252f%2D392c%2D4f68%2Db820%2Da3053b9d4f24)).
    Execution Time=26.5933938531294    306c809c-66a1-d0d5-d8e2-89d3631ce1bf
    Your help is very much appreciated.
    With Respect,
    Larry

    Yes, actually - I was able to resolve it.
    However I don't know how, unfortunately.  I suspect it was because I needed to have the names of the certificates, defined during the certificate registration (to sharepoint) process, different.
    I have a complete document that shows step by step instructions on the exact process I took to complete the provider hosted application creation, deployment and publishing.  It was a daunting task, but I finished it successfully.
    If there's a way to send private message on this forum, please do so and I'll respond with a way to obtain my document.
    NOTE:  I'm not all impressed with the way this forum works.  This is supposed to be a Microsoft resource and I'll be damned if I ever get a response to highly technical questions.  Completely lame.  Boooooo Microsoft.

  • Security certificate issue for Provider Hosted App (SP Online)

    Hi all,
    I am having a hard time with SP Online debugging a basic provider hosted app.
    Steps I have taken to create the app:
     created a new provider hosted app in Visual Studio 2013 and setting my SP Online debugging site (wich works perfectly for SP hosted apps).
    Chose Azure ACS option, although I do not have an Azure account
    When I deploy the app I get to the page on my debugging site where I must choose "Trust It", but when I do I get the message that the Connection is Unsecure/unsafe:
     How can I fix this? Do I need to create an Azure account for debugging purposes already? Or is there another way to solve the problem?

    Hi,
    I understand that you get Security certificate issue for Provider Hosted App (SP Online).
    Per my knowledge, you need to create an Azure account for debugging purposes.
    To create a SharePoint 2013 app for Office 365 and publish it to an Azure web site, you can refer to:
    http://blogs.msdn.com/b/kaevans/archive/2014/02/24/creating-a-sharepoint-2013-app-with-azure-web-sites.aspx
    Best Regards,
    Linda Li
    Linda Li
    TechNet Community Support

  • Provider-Hosted app intermittent 401 error

    Hi All,
      I've a PH high trust app which is working fine, but at times
    (not always) I'm getting 401 un-authorzed error. This is very intermittent error occurs when the app trys to access sharepoint. when the user refreshes the page its working fine.
    I've digged ULS log but couldn't find anything useful. However in event viewer found the below error.. I'm totally out of clues why its occurring only at times. Any help is appreciated. Thanks!
    Event code: 3005
    Event message: An unhandled exception has occurred.
    Event time: 1/5/2015 8:39:08 AM
    Event time (UTC): 1/5/2015 1:39:08 PM
    Event ID: 26b14be284ca4488abb0a5bba127c4c1
    Event sequence: 28
    Event occurrence: 1
    Event detail code: 0
    Application information:
        Application domain: /LM/W3SVC/2/ROOT-1-130649382841483100
        Trust level: Full
        Application Virtual Path: /
        Application Path: C:\TestWeb\
        Machine name: APPSERVER
    Process information:
        Process ID: 3408
        Process name: w3wp.exe
        Account name: Domain\ServiceAccount
    Exception information:
        Exception type: WebException
        Exception message: The remote server returned an error: (401) Unauthorized.
       at System.Net.HttpWebRequest.GetResponse()
       at Microsoft.SharePoint.Client.SPWebRequestExecutor.Execute()
       at Microsoft.SharePoint.Client.ClientRequest.ExecuteQueryToServer(ChunkStringBuilder sb)
       at App.Pages.WebForm1.Page_Load(Object sender, EventArgs e)
       at System.Web.UI.Control.LoadRecursive()
       at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
    Request information:
        Request URL: https://appsSite.domain.com/Pages/DisplayPage.aspx?a=EU/gibbs/35&SPHostUrl=http://SPSite.domain.com/sites/TestSite
        Request path: /Pages/DisplayPage.aspx
        User host address: 10.x.x.x
        User: Domain\User
        Is authenticated: True
        Authentication Type: Negotiate
        Thread account name: Domain\ServiceAccount
    Thread information:
        Thread ID: 14
        Thread account name: Domain\ServiceAccount
        Is impersonating: False
        Stack trace:    at System.Net.HttpWebRequest.GetResponse()
       at Microsoft.SharePoint.Client.SPWebRequestExecutor.Execute()
       at Microsoft.SharePoint.Client.ClientRequest.ExecuteQueryToServer(ChunkStringBuilder sb)
       at APP.Pages.WebForm1.Page_Load(Object sender, EventArgs e)
       at System.Web.UI.Control.LoadRecursive()
       at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
    Custom event details:

    Hi,
    According to your post, my understanding is that Provider-Hosted app get intermittent 401 error.
    If you use IssuerId in provider-hosted application web.config, please make it a lowercase Guid string.
     You need to make sure that the app certificate is added to the trusted certificate store.
    In addition, you can turn off the HTTPS using PowerShell.
    More information:
    http://www.jamestsai.net/Blog/post/SharePoint-Provider-Hosted-App-401-Unauthorized-error-on-clientContextExecuteQuery().aspx
    http://srichallagolla.blogspot.com/2013/01/sharepoint-2013-provider-hosted-high.html
    Best Regards,
    Linda Li
    Linda Li
    TechNet Community Support

Maybe you are looking for