Thursday 21 January 2016

Challenges In Developing Apps for SharePoint 2013

As most of you would know by now, that SharePoint 2013 app development is supported in 2 ways:

    Napa tools development
    Here the development environment is hosted inside a browser and no local installation is needed.

Developing Apps SharePoint 2013 - 1

    Visual Studio 2012
    Here you install VS 2012 and all the related tools (Office Developer Tools for Visual Studio 2012 and the SharePoint Client Components) on your local machine and do the development without installing SharePoint 2013 locally.

But what about the traditional way of development – where you have SharePoint and Visual Studio and tools, everything locally and do the deployment and testing without much fuss? Remember setting up a SharePoint developer workstation?

Well, that was when the whole thing started getting a little complicated with SharePoint 2013. Let’s get to the story now.

Following the developer environment setup from a TechNet Blog, I created a new Windows Server 2012 VM with 16 GB RAM, a SQL Server 2012 VM, installed SharePoint 2013, installed VS 2012 and Office Developer Tools, had my developer site ready (oh! yes, you need to create a “developer” site because with VS 2012, you cannot deploy to any other site than a “developer” site, though not true for local deployments). Fun enough? More to come…

Developing Apps SharePoint 2013 - 2

Mostly when developing on local machine, you are logged in using a single account, which is most likely also the local windows administrator as well as system account for SharePoint 2013. That’s how I do it, if you do it differently, I would love to hear why!
Now you have the basic stuff in place, let’s start the App development for SharePoint 2013. I will try to cover the steps to create and deploy a “hello world” app on local SharePoint developer site directly through VS 2012. I would assume that by now you have everything installed on your local machine, including SharePoint 2013.


1. Make sure you have SharePoint 2013 up and running on your local machine and have a developer site created. Then go ahead and launch VS 2012 and choose to create SharePoint 2013 App Project template.

Developing Apps SharePoint 2013 - 3

2. UAC – This is very thing you would notice (if you are on default UAC settings), even starting to develop the SharePoint 2013 app you need to start in elevated mode. Ok, most of us are now used to UAC prompts, so this gets out of way quickly.

Developing Apps SharePoint 2013 - 4

3. Now you get a familiar dialog asking for the Application name and site where to deploy it for debugging with an additional dropdown, asking for type of application you want to create based on . I chose SharePoint-Hosted app model.

Developing Apps SharePoint 2013 - 5

4. Now you are into the development mode and you get the skeleton code for the app in the solution.

Developing Apps SharePoint 2013 - 6

5. So we can just go ahead and deploy the skeleton app. You can directly hit F5 to deploy the app and open the URL or right-click on Project in Solution Explorer and select Deploy.
But the app did not deploy, rather I got the error: “Error occurred in deployment step ‘Install app for SharePoint’: The System Account cannot perform this action”.

But, isn’t the System Account supposed to be the God account in SharePoint?

Developing Apps SharePoint 2013 - 7

This is a security feature in the SharePoint 2013 that you cannot deploy an app using System Account. So what is the alternative?

Create another account and give permissions, so that it is NOT the system account.

6. So I did the following:

    Created a new account in AD as “admin1”
    Added “admin1” account into Farm Administrator’s group in Central Admin
    Added “admin1” account as Site Collection administrator to the target developer site
    Added “admin1” account into local administrators group

7. After doing the steps, I fired up VS 2012 using “admin1” credentials and created a new App for SharePoint 2013.

8. In the “New App for SharePoint” dialog, I clicked on “Validate” button and this is what I get:

Developing Apps SharePoint 2013 - 8

Rechecked that the user has got Farm Admin permissions and Site Collection administrator roles. But I still got the same error.

9. I just ignored the error and click on Finish to create the App

10. Then hit F5 to deploy and I get the following error:
Error occurred in deployment step ‘Uninstall app for SharePoint’: The local SharePoint server is not available. Check that the server is running and connected to the SharePoint farm.

That reaffirmed that some permissions are missing somewhere, as VS is not able to reach the SharePoint farm itself.

11. I decided to start by looking into event logs and found this error easily:

SQL database login for ‘SharePoint_Config_2013′ on instance ‘sql08′ failed. Additional error information from SQL Server is included below.

Login failed for user ‘DEVadmin1′.

12. Permissions are missing on Config DB, but won’t adding a user to Farm Administrators group give proper permissions? Looks like that is not the case.Then I remembered long ago I had written 1 KB article while at Microsoft, talking about permissions required for SharePoint Object Model.

13. Next target, add “admin1” user as DBO on Config DB. Go back to SharePoint VM and hit F5 again. A new error pop’s up:

Error occurred in deployment step ‘Uninstall app for SharePoint’: Cannot connect to the SharePoint site:http://sp2013/sites/AppDev/. Make sure that this is a valid URL and the SharePoint site is running on the local computer. If you moved this project to a new computer or if the URL of the SharePoint site has changed since you created the project, update the Site URL property of the project.

14. Checking event viewer again revealed that permissions are also needed on the Content DB for the Site Collection.

15. Next, added “admin1”  as DB_Owner for Content DB also. Go back to SharePoint VM and hit F5 again. Again a new error pops up:

Error occurred in deployment step ‘Install app for SharePoint’: We’re sorry; we weren’t able to complete the operation, please try again in a few minutes. If you see this message repeatedly, contact your administrator.

16. Checked event viewer, now AppMng_Service_DB requires permissions for “admin1” user. Back to SQL and give DB_Owner permissions on AppMng_Service_DB. Back to SharePoint, hit F5.

17. VoilĂ ! Finally the app is deployed and opened up in the browser!

Developing Apps SharePoint 2013 - 9

Finally had the sample app up and running after grueling fight with the “new” environment for a few hours! Hope this helps you in the same way… Happy Apps!

As most of you would know by now, that SharePoint 2013 app development is supported in 2 ways:
  • Napa tools development
    Here the development environment is hosted inside a browser and no local installation is needed.
Developing Apps SharePoint 2013 - 1
But what about the traditional way of development – where you have SharePoint and Visual Studio and tools, everything locally and do the deployment and testing without much fuss? Remember setting up a SharePoint developer workstation?
Well, that was when the whole thing started getting a little complicated with SharePoint 2013. Let’s get to the story now.
Following the developer environment setup from a TechNet Blog, I created a new Windows Server 2012 VM with 16 GB RAM, a SQL Server 2012 VM, installed SharePoint 2013, installed VS 2012 and Office Developer Tools, had my developer site ready (oh! yes, you need to create a “developer” site because with VS 2012, you cannot deploy to any other site than a “developer” site, though not true for local deployments). Fun enough? More to come…
Developing Apps SharePoint 2013 - 2
Mostly when developing on local machine, you are logged in using a single account, which is most likely also the local windows administrator as well as system account for SharePoint 2013. That’s how I do it, if you do it differently, I would love to hear why!
- See more at: http://blog.aditi.com/enterprise_social/challenges-starting-developing-apps-sharepoint-2013/#sthash.DDlA20sG.dpuf

0 comments:

Post a Comment