In this post you will get basic understanding of app development in SharePoint 2013 using visual studio 2012.
Apps main purpose in SharePoint 2013 is to provide the specific functionality or information to a SharePoint site. While trying to develop your first App you might get lots of errors initially, so I am here to resolve those. The main aim of this post is to cover all possible errors and resolutions for those errors you might get during the development.
Once you develop these apps where you will store?. Before starting the app development you have to check what are the hosting models available in SharePoint 2013.
Below are Microsoft SharePoint hosting options available.
In this article we will use SharePoint-hosted option to develop our first app.
Do you want to learn more about Apps development?
Make sure your environment is up and running before starting the development of apps.
Set-up your development environment using below link:
Please check this article for configure the apps .
Make sure you don't miss even single step in the above articles, otherwise you will get issues during app development.
Have you completed setup the environment and app configuration?
If you have completed the setting up the development environment and apps configuration, then you are ready to go........
Open visual studio 2012, click on new project select Apps under office/SharePoint from which select project type as Apps for SharePoint 2013.
Enter your project name here it is MyFirstApp.
Click ok. It will open the wizard to create the project.
Select the site where you want to deploy the app. "http://sharepoint-journey.com/sites/appdevelopment".
Hosting option should be : SharePoint-hosted.
Click Finish. It will create the project.
Right click on the project and deploy it. You will get below error with SharePoint server RTM.
"Error occurred in deployment step "Installed app for SharePoint": The System Account cannot perform this action".
Note: You cannot deploy the apps with system account in RTM to provide the security.
So what to do?
Use another account to deploy the apps using visual studio 2012 from your development machine.
To do that login with the new account into the machine. Open the Project which you have created with system account before i.e. MyFirstApp.
Try to deploy it?.
You will get below error.
"Error occurred in deployment step "Installed app for SharePoint": The local SharePoint server is not available. Check that the server is running and connected to the SharePoint Farm"
To resolve the above error switch back to system account and open the SQL server management studio and assign the db_owner permissions to an account which you are using to deploy the app for below databases.
Provide full control permissions to the site collection where we are deploying the app.
Please check here to find a new way of assigning the permissions in SharePoint 2013.
Make sure that you have added that user under Farm administrators account from central administration.
You have all the required the permissions now, to cross verify try to browse the site "http://sharepoint-journey.com/sites/appdevelopment" where you want to deploy the app, if you are able to open the site, then you are ready to deploy the app.
Sometimes you may get errors like below in app development.
"Error occurred in deployment step "Installed app for SharePoint": App management Shared Service proxy is not installed".
To resolve the above error, you need to use step2 in app configuration article.
"Error occurred in deployment step "Installed app for SharePoint": Failed to install app for SharePoint. Please see the out put window for details"
To resolve the above error you need to configure the app catalog URLs from the central administration.
The above errors are occurring because you didn't follow the configuration guide to configure the apps. Please follow without missing any step, then you should not be getting any error.
Today when I try to deploy an App I got below error.
ErrorDetail: The content database on the server is temporarily unavailable.
ExceptionMessage: Microsoft.SharePoint.SPException: Settings or services required to complete this request are not currently available. Try this operation again later. If the problem persists, contact your administrator.
at Microsoft.SharePoint.SPSubscriptionSettingsServiceApplicationProxy.ProcessCommonExceptions(Exception ex, SPServiceLoadBalancerContext context)
at Microsoft.SharePoint.SPSubscriptionSettingsServiceApplicationProxy.ExecuteOnChannel(CodeBlock codeBlock)
at Microsoft.SharePoint.SPSubscriptionSettingsServiceApplicationProxy.GetSubscriptionMetadata(Guid subscriptionId)
at Microsoft.SharePoint.Utilities.SPUtility.IsValidAppInstallationConfiguration(SPSite site)
at Microsoft.SharePoint.Utilities.SPUtility.CanInstallAppsInSite(SPSite site)
SourceName: App Web Deployment
Error occurred in deployment step 'Install app for SharePoint': Failed to install app for SharePoint. Please see the output window for details.
We have already configured two essential service applications in our environment those are
To resolve the error, we need to configure one more service application. That is ..
3. Managed Metadata Service Application.
Once you deploy the app, it will show the below details in output window that App was installed at so and so location.
Congratulations you have developed your first app in SharePoint 2013 using visual studio 2012.
We will try to open the site and find out how it looks. Open the site from where you have deployed the app.
In this demo it is "http://sharepoint-journey.com/sites/appdevelopment".
Under the Recent section on left navigation you can observe the app which you have deployed click on that. It will open the below screen where you can see the message "Hello System Account" i.e. Logged in user name.
Observe one important thing is the URL where the app is running which is completely different compared to the site where we have deployed, that means your site will not get impacted by the app which you are going to deploy into that.
You have option on the top header navigation to go back to the site.
The above "System Account" is displayed using below code which is using CSOM (Client Side Object Model).
We will see more about that in future articles.
In the below code whenever you open the app, document. ready function will get called which in turn call the getUserName function where it uses the web.get_currentUser() method to get the current user details.
If the getUserName function is successful then we are displaying the title of the current user by calling
Note: you can't use server side code in SharePoint-hosted Apps.
To check app details, permissions and remove option, go to site contents section of your site settings link, you can see the app which you deployed.
Once you click the menu link it will open a popup and shows the below details
Please check the SharePoint-hosted Apps development video.
In this post we have seen how to develop a basic app development in SharePoint 2013 using visual studio.
How to resolve the errors which will come while developing the apps.
Devendra Velegandla is a four-time recipient of Microsoft's Most Valuable Professional (MVP) award (2014-2017) for Office Servers and Services MVP and SharePoint Server.He received the MCC award for his contributions in Microsoft MSDN/TechNet forums.He loves sharing articles, videos and tutorial on SharePoint and Office 365.