{"id":1817,"date":"2020-03-27T16:48:43","date_gmt":"2020-03-27T16:48:43","guid":{"rendered":"http:\/\/www.stuartroberts.net\/?p=1817"},"modified":"2020-07-18T16:37:49","modified_gmt":"2020-07-18T15:37:49","slug":"provider-hosted-development-setup","status":"publish","type":"post","link":"http:\/\/www.stuartroberts.net\/index.php\/2020\/03\/27\/provider-hosted-development-setup\/","title":{"rendered":"Provider-Hosted Development Setup"},"content":{"rendered":"\n<p>Setting up a development environment for SharePoint is relatively straight forward when it comes to on premise solutions. Everything is running on the same server and normally on one IIS website.<\/p>\n\n\n\n<p>Moving to a hybrid model, be that either SharePoint or Provider hosted requires some extra configuration. More so for provider-hosted as you need to configure DNS entries. Specifically, you&#8217;ll need to define domains for:<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Usage<\/th><th>DNS<\/th><th>Description<\/th><\/tr><\/thead><tbody><tr><td>SharePoint Portal<\/td><td>spportal.com<\/td><td>Standard DNS entry and certificate<\/td><\/tr><tr><td>Host Web<\/td><td>spportaladdin.com<\/td><td>Forward lookup zone entry for hosting provider-hosted add-ins<\/td><\/tr><tr><td>Host Web<\/td><td>*.spportaladdin.com<\/td><td>Wilcard alias (CNAME).<br>Each add-in when activated provisions a unique DNS domain name. Wildcard Canonical Name is required to support this.<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>For a development environment, adding DNS entries mat not be possible depending on how much access you have to fully administer the server. It&#8217;s also unnecessary for writing and testing add-ins locally. Other users, tester, etc., should not be accessing your development server for testing. That&#8217;s what UA environments are for, so it may be easier to bypass this configuration and setup the dev server to work without DNS entries.<\/p>\n\n\n\n<!--more-->\n\n\n\n<p>Installing SharePoint is a fairly straight forward process, especially for a development server. I won&#8217;t go into this for the post but the following gives a good description on how to install a single server SharePoint intsance &#8211; <a href=\"https:\/\/docs.microsoft.com\/en-us\/sharepoint\/install\/install-sharepoint-server-2016-on-one-server\">https:\/\/docs.microsoft.com\/en-us\/sharepoint\/install\/install-sharepoint-server-2016-on-one-server<\/a><\/p>\n\n\n\n<h2>Creation of host web domain<\/h2>\n\n\n\n<p>To create the host web domain, we&#8217;re simply going to add an entry to the hosts file<\/p>\n\n\n\n<ol><li>Go to C:\\Windows\\System32\\drivers\\etc<\/li><li>Open the file called <strong>hosts<\/strong> in a text editor<\/li><li>Add an entry to the bottom of the file<ul><li>127.0.0.1     spportaladdin<\/li><\/ul><\/li><li>Save the changes<\/li><\/ol>\n\n\n\n<h2>Disable Loopback checks<\/h2>\n\n\n\n<p>To allow all browsing to the server from IIS on which it&#8217;s hosted by using any host-header, we need to disable loopback checks in the registry.<\/p>\n\n\n\n<ol><li>Open the registry editor &#8211; C:\\Windows\\regedit.exe<\/li><li>Browse to the following folder<ul><li>HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\Lsa<\/li><\/ul><\/li><li>Add a new DWORD entry with the key &#8211; DisableLoopbackCheck<\/li><li>Modify it and set the value to 1<\/li><li>Reboot the machine to ensure the changes are applied<\/li><\/ol>\n\n\n\n<h2>Create the Host Web<\/h2>\n\n\n\n<p>Now lets create the host web in IIS<\/p>\n\n\n\n<ol><li>Open IIS Manager <\/li><li>Optionally create a new application pool for the host web<\/li><li>After this, right click Sites and select Add Website<\/li><li>Enter whatever site name you like<\/li><li>Change the application pool to the one you created above or simply choose the one used by your main SharePoint web application<\/li><li>Set a location for this new web site<ul><li>I created mine one level below where SharePoint creates them<\/li><li>C:\\inetpub\\wwwroot\\wss\\hostweb<\/li><\/ul><\/li><li>Add the domain created in the hosts file above into the Host Name input box.<ul><li>In this case &#8211; spportaladdin.com<\/li><\/ul><\/li><li>Click OK to apply the changes.<\/li><\/ol>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" loading=\"lazy\" width=\"577\" height=\"560\" src=\"http:\/\/www.stuartroberts.net\/wp-content\/uploads\/2020\/03\/Create-HostWebSite.png\" alt=\"\" class=\"wp-image-1855\" srcset=\"http:\/\/www.stuartroberts.net\/wp-content\/uploads\/2020\/03\/Create-HostWebSite.png 577w, http:\/\/www.stuartroberts.net\/wp-content\/uploads\/2020\/03\/Create-HostWebSite-300x291.png 300w\" sizes=\"(max-width: 577px) 100vw, 577px\" \/><\/figure>\n\n\n\n<p>Once created, go to the Authentication setting for the new website. From here, set Anonymous and Windows authentication to Enabled.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" loading=\"lazy\" width=\"470\" height=\"216\" src=\"http:\/\/www.stuartroberts.net\/wp-content\/uploads\/2020\/03\/WebSite-Authentication.png\" alt=\"\" class=\"wp-image-1842\" srcset=\"http:\/\/www.stuartroberts.net\/wp-content\/uploads\/2020\/03\/WebSite-Authentication.png 470w, http:\/\/www.stuartroberts.net\/wp-content\/uploads\/2020\/03\/WebSite-Authentication-300x138.png 300w\" sizes=\"(max-width: 470px) 100vw, 470px\" \/><\/figure>\n\n\n\n<p>Now we need to grant permission to the host web&#8217;s folder for the application pool<\/p>\n\n\n\n<ol><li>In Windows Explorer, go to the parent folder of the website you just created<\/li><li>Right click the website&#8217;s folder then choose Properties<\/li><li>Switch to the Security tab<\/li><li>Click the Edit button near the top of the page<\/li><li>Now click Add<\/li><li>In the dialog that appears, click the Locations button<\/li><li>Ensure the computer is selected here and then click OK<\/li><li>Enter the application pool account in the text box<ul><li>Taking the example above, to add &#8216;SharePoint &#8211; Apps&#8217;, I&#8217;d enter:<\/li><li>IIS AppPool\\SharePoint &#8211; Apps<\/li><\/ul><\/li><li>Click OK to add the account<\/li><li>With the account highlighted, set the permissions to:<ul><li>Read &amp; Execute<\/li><li>List folder contents<\/li><li>Read<\/li><\/ul><\/li><li>Click OK to apply the changes<\/li><\/ol>\n\n\n\n<h2>Service Applications<\/h2>\n\n\n\n<p>Now we need to create two service applications. We need the Application Management and Subscription Settings services.<\/p>\n\n\n\n<p>Before creating the services, ensure the Microsoft SharePoint Foundation Subscription Settings Service has auto provisioning set to Yes. If not, click Enable Auto Provisioning<\/p>\n\n\n\n<ol><li> Open Central Administration<\/li><li>Click &#8216;Manage Services in this Farm&#8217;. Located under the System Settings heading<\/li><li>Verify auto provisioning is enabled and set to on if it&#8217;s not<\/li><\/ol>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" loading=\"lazy\" width=\"1024\" height=\"177\" src=\"http:\/\/www.stuartroberts.net\/wp-content\/uploads\/2020\/03\/Enable-AutoProvisioningSubSettings-1024x177.png\" alt=\"\" class=\"wp-image-1844\" srcset=\"http:\/\/www.stuartroberts.net\/wp-content\/uploads\/2020\/03\/Enable-AutoProvisioningSubSettings-1024x177.png 1024w, http:\/\/www.stuartroberts.net\/wp-content\/uploads\/2020\/03\/Enable-AutoProvisioningSubSettings-300x52.png 300w, http:\/\/www.stuartroberts.net\/wp-content\/uploads\/2020\/03\/Enable-AutoProvisioningSubSettings-768x133.png 768w, http:\/\/www.stuartroberts.net\/wp-content\/uploads\/2020\/03\/Enable-AutoProvisioningSubSettings.png 1491w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>After setting above, use the following PowerShell to create the two services:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: powershell; title: ; notranslate\" title=\"\">\n# Change this to the managed service account you use for your services\n$account = Get-SPManagedAccount &quot;domain\\setupaccount&quot;\n\n# Optionally create application pools for both services\n# Alternatively use the default application pool\n# $appPool = Get-SPServiceApplicationPool -Identity &quot;SharePoint Web Services Default&quot;\n$appPoolSubSvc = New-SPServiceApplicationPool -Name 'Subscription App Pool' -Account $account\n$appPoolAppSvc = New-SPServiceApplicationPool -Name 'App Management App Pool' -Account $account\n\n# Change the Name and DatabaseName to whatever you like\n$appSubSvc = New-SPSubscriptionSettingsServiceApplication -ApplicationPool $appPoolSubSvc -Name 'Subscription Settings Service' -DatabaseName SettingsServiceDB  \n$proxySubSvc = New-SPSubscriptionSettingsServiceApplicationProxy -ServiceApplication $appSubSvc\n\n$appAppSvc = New-SPSubscriptionSettingsServiceApplication -ApplicationPool $appPoolAppSvc -Name 'Application Management Service' -DatabaseName AppServiceDB \n$proxyAppSvc = New-SPSubscriptionSettingsServiceApplicationProxy -ServiceApplication $appAppSvc\n<\/pre><\/div>\n\n\n<p>Once the above has completed you should now see two new services listed in the Manage Service Applications page:<\/p>\n\n\n\n<ol><li>Application Management Service &amp; its proxy<\/li><li>Subscriptions Settings Service &amp; its proxy<\/li><\/ol>\n\n\n\n<h2>Configure Environment for Add-Ins<\/h2>\n\n\n\n<p>Now the required services are up and running, we now need to configure the farm for add-ins. You can do this via Central Administration or PowerShell.<\/p>\n\n\n\n<p>For Central Administration, go to the \/_admin\/ConfigureAppSettings.aspx page and enter the domain and prefix values:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" loading=\"lazy\" width=\"851\" height=\"284\" src=\"http:\/\/www.stuartroberts.net\/wp-content\/uploads\/2020\/03\/Configure-AppUrls.png\" alt=\"\" class=\"wp-image-1859\" srcset=\"http:\/\/www.stuartroberts.net\/wp-content\/uploads\/2020\/03\/Configure-AppUrls.png 851w, http:\/\/www.stuartroberts.net\/wp-content\/uploads\/2020\/03\/Configure-AppUrls-300x100.png 300w, http:\/\/www.stuartroberts.net\/wp-content\/uploads\/2020\/03\/Configure-AppUrls-768x256.png 768w\" sizes=\"(max-width: 851px) 100vw, 851px\" \/><\/figure>\n\n\n\n<p>Using PowerShell, simply run the following two commands:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: powershell; title: ; notranslate\" title=\"\">\nSet-SPAppDomain -AppDomain spportaladdin\nSet-SPAppSiteSubscriptionName -Name addin -Confirm:$false\n<\/pre><\/div>\n\n\n<p>For development purposes, you should only need to create  development site to deploy and test the add-ins you develop. To create one, simply create a new site in Central Admin based on the Developer Site template:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" loading=\"lazy\" width=\"506\" height=\"267\" src=\"http:\/\/www.stuartroberts.net\/wp-content\/uploads\/2020\/03\/Create-DeveloperSite.png\" alt=\"\" class=\"wp-image-1860\" srcset=\"http:\/\/www.stuartroberts.net\/wp-content\/uploads\/2020\/03\/Create-DeveloperSite.png 506w, http:\/\/www.stuartroberts.net\/wp-content\/uploads\/2020\/03\/Create-DeveloperSite-300x158.png 300w\" sizes=\"(max-width: 506px) 100vw, 506px\" \/><\/figure>\n\n\n\n<p>Nothing wrong with also creating the app catalog for the web application too, if you want to test deploying the add-ins to different test site collections that you create. To do this, you need to go to the Manage App Catalog page in Central Admin &#8211; \/_admin\/ManageCorporateCatalog.aspx<\/p>\n\n\n\n<p>From here, select Create a new app catalog site and provide the title, description and URL like you would when creating any other site collection.<\/p>\n\n\n\n<p>To do the above with PowerShell:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: powershell; title: ; notranslate\" title=\"\">\n# Change the Url and OwnerAlias to match your environment\nNew-SPSite -Url http:\/\/yourservername\/sites\/AppCatalog -OwnerAlias &quot;domain\\setupaccount&quot; -Name &quot;App Catalog site&quot; -Template &quot;APPCATALOG#0\n<\/pre><\/div>\n\n\n<p>One last thing you should do before you&#8217;re able to start debugging and deploying custom add-ins is to configure the trusted certificate with SharePoint. To do this, follow the post <a href=\"http:\/\/www.stuartroberts.net\/index.php\/2020\/04\/10\/register-self-signed-certificate\/\" class=\"aioseop-link\">here<\/a>.<\/p>\n\n\n\n<p>Your SharePoint server should now be up and running and ready for you to deploy your first add-in to it. The <a href=\"\/index.php\/2020\/07\/18\/developing-a-provider-hosted-add-in\/\">following<\/a> is a post detailing how to create and deploy a fairly simple provider-hosted add-in.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Setting up a development environment for SharePoint is relatively straight forward when it comes to on premise solutions. Everything is running on the same server and normally on one IIS website. Moving to a hybrid model, be that either SharePoint &hellip; <a href=\"http:\/\/www.stuartroberts.net\/index.php\/2020\/03\/27\/provider-hosted-development-setup\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_mi_skip_tracking":false,"jetpack_post_was_ever_published":false,"jetpack_publicize_message":"","jetpack_is_tweetstorm":false,"jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":[]},"categories":[33,32,3],"tags":[94,88,24,93,100],"jetpack_publicize_connections":[],"aioseo_notices":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/plx2I-tj","_links":{"self":[{"href":"http:\/\/www.stuartroberts.net\/index.php\/wp-json\/wp\/v2\/posts\/1817"}],"collection":[{"href":"http:\/\/www.stuartroberts.net\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.stuartroberts.net\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.stuartroberts.net\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.stuartroberts.net\/index.php\/wp-json\/wp\/v2\/comments?post=1817"}],"version-history":[{"count":26,"href":"http:\/\/www.stuartroberts.net\/index.php\/wp-json\/wp\/v2\/posts\/1817\/revisions"}],"predecessor-version":[{"id":1954,"href":"http:\/\/www.stuartroberts.net\/index.php\/wp-json\/wp\/v2\/posts\/1817\/revisions\/1954"}],"wp:attachment":[{"href":"http:\/\/www.stuartroberts.net\/index.php\/wp-json\/wp\/v2\/media?parent=1817"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.stuartroberts.net\/index.php\/wp-json\/wp\/v2\/categories?post=1817"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.stuartroberts.net\/index.php\/wp-json\/wp\/v2\/tags?post=1817"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}