In this post I will explain in details how to provision Lists and list items using a Provider hosted app and a declarative XML files to define List Schema and Sample data items. This tutorial will use the App installed and uninstalled remote event receivers to do the task!

First what you need to have is:

  1. SharePoint online or Office365 subscription.
  2. Visual Studio.
  3. Windows Azure subscription.
  4. Sellerdashboard account 
What you need to do is:

  1. Create new SharePoint App project 
  2. Choose the app to be provider hosted and choose your target site
  3. Login  to your Office365
  4. Create a Folder Called ListDefinitions
  5. Under the folder create 2 XML files for 2 custom lists 
    1. CountryList.xml
    2. CityList.xml
  6. Enable the App remote event receivers for both installed and uninstalling events.
  7. As you can see I've created 2 methods in the AppEventReceiver.svc.cs to handle List Creation and deletion.
  8. Now to your Azure subscription we need to create a website to host our event receivers
  9. Download the publishing profile
  10. Create ClientId  for your app.


  11. Import your publishing profile
  12. Publish the app using the obtained Client key and secret

  13. Upload the app to your app catalog or simply run the SharePoint solution 

  14. Add the app
  15. Trust the app.
  16. wait for a while until the remote event receiver creates the two custom lists and add the sample data items to them.
  17. You can check the inserted data and the correct lookup column reference in the city list

You can download the code sample from here