torsdag 28 februari 2013

Create a high-trust provider hosted app for SharePoint 2013

In my current assignment, I had to create a provider hosted app. I spend about a day reading different guides online but none provided me with a working solution. I finally got it up and running and I thought I should share it.

Im running both SharePoint and the provider hosted web application on the same server.

Create certificate 

First of you need a X.509 certificate with a public and private key pair. The public key is used to register a trusted security token issuer in SharePoint and the private key is used to secure the remote web application.

I wrote a PowerShell script (Make-Cert.ps1) to help creating the certificate and install it on IIS. It accepts the following parameters:
  • Domain: The url to the provider hosted web application. E.g. www.contoso.com.
  • OutputDir: The folder where the certificates are created.
  • Password: The password for the private certificate.

Create IIS app web

Create a new web site in IIS and bind it to SSL with the newly created certificate. This is where you will deploy your provider hosted app.

Click on the newly created web site and double click the IIS Authentication icon.
Disable Anonymous Authentication and enable Windows Authentication.

Configure an S2S trust

You need to create a trust between SharePoint and the certificate used by the app. I wrote another PowerShell script (Configure-S2S.ps1) for this. The script accepts the following parameters:
  •  publicCertPath: The full path to the *.cer file
  •  spUrl: The url to the SharePoint site where the app will be installed
  •  trustName: A name for the trust
  •  issuerId (not mandatory): You can use a pre-defined issuer id or you can have the script generate an id for you by leaving it blank.

Copy the issuer id from the script output.

Register your provider hosted app

Go to http://<your sharepoint site>/_layouts/15/appregnew.aspx
  •  Generate App Id and Secret
  •  Title: Enter the name of your app
  •  App Domain: The app domain registered in your app service. Get the url from http://<central admin>/_admin/ConfigureAppSettings.aspx
  •  Redirect url: The url to the first page of your app (https://www.myiissite.com/pages/default.aspx)
Copy the output from the page.

Create a new provider hosted app

Open Visual Studio 2012 and create a new App for SharePoint 2013 project.

The name of the app should be the same as the one you entered in appregnew.aspx

Password: The password provided in Make-Cert.ps1
Issuer ID: From the Configure-S2S.ps1 output

Open web.config in the TestAppWeb project and updat the following app setting keys:
  •  ClientId: The guid generated in appregnew.aspx
  •  ClientSecret: The secret generated in appregnew.aspx
Right click the SharePoint project and select Publish:
Give the profile a name and click Next


Copy the Client Id and Secret from the output from appregnew.aspx
Click Next and Finish

Deploy your provider hosted app

Go to the generated package
Open *.Web.SetParameters.xml in Notepad.
Update the IIS Web Application Name to the name of your web site (as shown in IIS Manager)
Open a command prompt and run the *.Web.deploy.cmd script with the switch /Y
This will deploy all the resources to your web site.
Upload the *.app file to your app catalog.
Add the app to your site.

42 kommentarer:

  1. Hey Martin,

    Please help how to deploy this above created app to another SharePoint server.
    Regards,
    Siva

    SvaraRadera
  2. Hi Siva,
    what do you mean by "another SharePoint server"? Are you running your provider-hosted app and SharePoint on two different servers?

    If so, complete the steps "Create IIS app web" and "Deploy your provider hosted app" on the provider hosted app server (apart from uploading the *.app file and adding the app to your site (from Site Contents), this is done from any browser).

    All other steps should be completed on your SharePoint box.

    Hope this helps!

    Regards,
    Martin

    SvaraRadera
  3. Hi Martin,

    I have another server having IIS + SharePoint. I want to deploy my provider hosted app in this server. Problem is that, I have uploaded the app file, run the webdeploy.cmd file. The site is created & I can see the app & run also. But the page goes to 401-unauthorised. My doubt is: configuration of Certificate(generated in dev environment). I think here is some mistake. I followed your steps, created the app & it running successfully in dev pc. Now I want it to deploy to another pc, having sharepoint + iis.

    Regards,
    Siva

    SvaraRadera
  4. there is something wrong in step "Register your provider hosted app"

    App Domain: The app domain registered in your app service. Get the url from http:///_admin/ConfigureAppSettings.aspx

    Should be:

    App Domain: The host name of the remote component of the app for SharePoint. If the remote application isn't using port 443, the app domain must also include the port number. That is, the app domain must match the URL bindings you use for your web application. There should be no protocol ("https:") or "/" characters in this value. (If your web application host is using a DNS CNAME alias, use the alias.) Some examples:

    SvaraRadera
  5. Wohh I love it, I mean this blog is just awesome. I personally love this informative article… Keep posting such information… Keep Going!
    Germany VPS Hosting

    SvaraRadera
  6. Den här kommentaren har tagits bort av skribenten.

    SvaraRadera
  7. Den här kommentaren har tagits bort av skribenten.

    SvaraRadera
  8. first thanking to you make a blog on create a high trust provider hosted apps for share point. If you want to know about server hosting or interested in best USA VPS hosting you can ask us for more details and services. For fastest hosting server join with us.

    SvaraRadera
  9. Nice Blog
    Your blog is very instructive for IT people like me. Keep sharing this type of blog it really helps us. Web Hosting plays a very important role in the business world. And it is important to have the best hosting services. Buy the best USA VPS Hosting service for your website.

    SvaraRadera
  10. Nice...I Really Like Your Article Its look like You Spent a Lot of Time and Effort on Your Blog...
    When I read your blog "Martins SharePoint Corner" then i realize its very hard to get right information form internet your explanation is very well.USA VPS You are sharing is good for this generation and i surely share this article to my friends and near once and i would like to give you thkxx again...

    SvaraRadera
  11. outstanding blog and so informative content in this blog Create a high-trust provider hosted app for SharePoint 2013
    In my current assignment, I had to create a provider hosted app. I spend about a day reading different guides online but none provided me with a working solution. I finally got it up and running and I thought I should share it. If you want to know about server hosting or interested in best Italy VPS Hosting you can ask us for more details and services.

    SvaraRadera
  12. Nice Blog and Great article…its always working for me well…Keep going thank you for a blog about Create a high-trust provider hosted app for SharePoint 2013. In my current assignment, I had to create a provider hosted app. I spend about a day reading different guides online but none provided me with a working solution. I finally got it up and running and I thought I should share it.If you want to start your online business with fast hosting service, or interested to know about the best Greece VPS Hosting you can ask us for more details.

    SvaraRadera
  13. Your blog is so marvelous and everything is a proper way to write about I spend about a day reading different guides online but you provided me with a working solution. I share such information especially about Norway VPS Hosting you can ask us for more details about hosting services.

    SvaraRadera
  14. Great Blog !
    It's very informative and attractive. it very helpful of all kinds. I get the best info from this blog. I am always read your blog. It's a very informative blog. Are you know that what is Hong Kong VPS Hosting? if no, then I can help you and I will give you the best info.
    Thank you so much for the nice info...

    SvaraRadera
  15. this blog is very amazing and informative I am glad to you for share it. if you want to know about server hosting or are interested in the best Malaysia VPS Hosting you can contact us for more details and services. By click on Malaysia VPS Hosting

    SvaraRadera
  16. your blog is so simple and easy to read and thankyou for making a blog on Create a high-trust provider hosted app for SharePoint 2013. In my current assignment, I had to create a provider hosted app. If you want to start your online business with fast hosting service. If you are interested in best Australia VPS Hosting you can choose your plans as your requirement.

    SvaraRadera
  17. Nice Blog...
    I read your blog it is very informative for me. I appreciate your blog. Thank you very much for sharing. I would be happy to share this blog with my friends. Here I want to share some of the best Dubai VPS Server service for your website at very cheap price. I would be very glad to help you.

    SvaraRadera
  18. Great post. I was checking continuously this blog and I am impressed! Are you want to know that what is Canada VPS Hosting ? if no, then I can help you and I will give you the best info.

    SvaraRadera
  19. Informative blog, thanks for sharing this blog. includes almost all important info about share point. I liked. I am sure you don't want that your website faces any problems. we give a better Brazil VPS Serverservice for your website and enjoy it to the fullest.

    SvaraRadera
  20. Your blog is really informative you explained everything is in a very simple way thank you for sharing. I share good information about UK VPS Hosting if anyone wants to take knowledge regarding UK VPS Hosting, I will be happy to tell you.

    SvaraRadera
  21. Thank you!
    It's a very helpful & informative blog for me and others. I would be happy to share this information with a good person and my friend. Here I want to share some of the best USA VPS Hosting services for your website at a reasonable price. I would be very glad to help you. thanks a lot.....again

    SvaraRadera

  22. I've read a lot of blog comments and, let me tell your blog was really awesome tnx for Create a high-trust provider hosted app for SharePoint 2013.If you are looking for fastest and cheapest Germany VPS Hosting you can ask us for more details and services.

    SvaraRadera
  23. Great post. I was reading continuously this blog and I am impressed! also, I want to share some information on VPS Hosting the best Russia VPS Hosting services are very helpful to handle traffic of your business website also at the very cheapest price.

    SvaraRadera
  24. First thanking to you make a blog on create a high trust provider hosting for share point. If you want to know about server hosting or interested in best Turkey VPS Hosting you can ask us for more details and services. For fastest hosting server join with us.

    SvaraRadera
  25. Wow! amazing blog posting by you. thank you very much. It information is very helpful in this blog related to Create a high-trust provider hosted app for SharePoint 2013. If you are looking for fastest and Best Cheap VPS you can ask us for more details and services.

    SvaraRadera
  26. Amazing! this information is very helpful for me. You can also check fascinating VPS Cloud Hosting services.

    SvaraRadera
  27. Nice blog, its always working for me. I really like your article and i get the best information from this blog.You can also check our best Swiss Cloud VPS Services for hosting.

    SvaraRadera
  28. Thanks for ones this excellent posting, I actually enjoyed
    reading it, you are a great author. Here I also want to share some information on the best Instant Domain Search services for your business website at a very affordable price.

    SvaraRadera
  29. Gοod way of ԁеscribіng, anԁ fastidіоus piеcе of writing tο take informаtіоn about my presentatіοn subjеct mаtter. Thanks for sharing this post. And, also I want to suggest you buy a Managed WordPress Hosting .

    SvaraRadera
  30. I read your blog, it is very helpful to us. I'm very glad that I got valuable info on your blog. Do you want to most valuable info about Fastest
    WordPress Hosting? then Fastest WordPress Hosting I will help you, after that you can choose the best plans as your requirement from Onlive Server.

    SvaraRadera
  31. Awesome blog! I read this blog it is very Informative. Keep sharing this type of blog it really helps us. If you want some information about VPS Windows 10 for your business website. then you can contact us and you can ask me any queries related to VPS Hosting Services.

    SvaraRadera
  32. Simple but very accurate information… Thanks for sharing this one. A must-read post! I share such information especially about Cheap Linux VPS if anyone wants to take knowledge regarding it, then I would love to help you.

    SvaraRadera
  33. I like your articles. your article must be good and easily understandable. I really impressed by your post. I am going to share your post on my Linkedin page. Thanks for sharing this post. Also, I can help you with VPS Hosting For WordPress.

    SvaraRadera
  34. Your blog is very informative for IT people same me. Continue sharing this kind of blog it actually helps us. Web Hosting represents a particularly important role in the business world. And it is important to have the best hosting services. If you are looking for the perfect domain name Domain name availability you can ask us for more details and services.

    SvaraRadera
  35. Which I love, I mean this blog is just awesome. I personally love this informative article. Keep posting such information. USA Dedicated Server

    SvaraRadera
  36. Create a high-trust provider hosted app for SharePoint 2013 this information is very useful and informative. At last, I want to thank you for this wonderful post. If you want to take knowledge about Cloud VPS Hosting , you must ask about it.

    SvaraRadera
  37. You always make a very informative and useful for everyone this time you make a great video on Airtel! New proxy only for mobile. At last, I want to thank you for this wonderful post. If you want to take knowledge about Cloud VPS Hosting , you must ask about it.

    SvaraRadera
  38. Nice Information and Nicely you explained everything in your article. Thanks for your information, this is nice and helpful. Definitely going to share this article with my friends.Best Cheap VPS

    SvaraRadera
  39. Your article, no doubt, is very informative and easy to read. i recommended it to others also. If you want to read Best World News so you can check out Stoptechy.

    SvaraRadera
  40. Amazing!! This blog is quite informative and beneficial. I appreciate your information a lot. This organization offers fantastic service throughout! Above and beyond all expectations, professional assistance is provided 24/7. You can ask us for additional information if you want to launch your internet business with the best hosting service or are curious about the top Australia VPS Server .

    SvaraRadera
  41. Your gratitude is deeply appreciated, and it motivates me to continue crafting content that can serve as a valuable resource. If you're eager to expand your knowledge further or have specific inquiries, do not hesitate to reach out. Whether it's diving deeper into SharePoint, exploring its integration capabilities, or understanding the best practices for hosted app development, your questions are always welcome.You Want to VPS Hosting then Visit Our Site.USA VPS Server

    SvaraRadera