Cloud Meta Man – Getting Started

Cloud Meta Man is our tool that will generate all required code for you that you can easily provide the business data stored away on premise databases usually running behind multiple firewalls or NAT devices. You will be able to use generated WCF service, host it on Windows Azure and easily integrate it with the Business Connectivity Services running in the cloud or on-premise. You will be able to use generated ASP.NET MVC 3 Web Role, host it on Windows Azure and easily display the data returned across the Service Bus on the web page. In this walkthrough using Cloud Meta Man we will create Listener and Caller console applications, ASP.NET MVC 3 Web Role and WCF layer with CRUD operations for on-premise MS SQL database, host the roles on Windows Azure and make the data available on SharePoint page.

  1. Prerequisites
  • Cloud Meta Man version 1.0.0.4 or hire
  • Microsoft SharePoint Server 2010
  • Microsoft Visual Studio 2010 Professional or higher
  • Windows Azure SDK for .NET installed
  • A subscription on Windows Azure
  • We need to create a service bus within Azure.
  • Login to Windows Azure and click the “Service Bus, Access Control & Caching” on the left pane
    click the “Service Bus, Access Control & Caching”
  • Then click on the Service Bus node that is displayed in the tree
    click on the Service Bus node
  • Create a new Service Namespace – type a Namespace name, pick a country and the subscription.
    Create a new Service Namespace
  • Once the service bus is provisioned click on the service bus name under the Subscription node so you see the properties in the right hand pane
    Service Bus properties
  • Click on the button to view the Default Key, you’ll need these details shortly
    Default Key
  • Open Visual Studio 2010
  • Add a New Project
  • Select “Visual C#” node, then the “Cloud Meta Man” project type
  • Give your project a name i.e “CloudMetaMan” and click “OK”

    Give your Cloud Meta Man project a name

  • In the Solution explorer right-click on the “Data Source Library” node, select “Add”->”New Item”

    Add new ADO.NET Entity Data Model item to the project

  • Select “Visual C# Items” node, then the “ADO.NET Entity Data Model” item type
  • Give your item a name i.e “MSSQLModel” and click “Add”

    Give your project item a name

  • In the “Entity Data Model Wizard” select “Generate from Database” and click “Next”

    Generate the model from database

  • On the next step click “New Connection” or use existing one

    Create new connection

  • If you clicked “New Connection”, select for example “Microsoft SQL Server (SqlClient)” and enter required information in order to connect to the database. Click “OK”

    Enter MS SQL connection properties

  • Now click “Next”

    Choose your created data connection

  • Select one object you want to include to the model. For example “Department” table and click “Finish”

    Select Department table

  • Your diagram should look like this

    Created table on the diagram

  • Expand “BCS Azure” project in the Solution explorer, right-click on “Roles” folder, select “Add”->“Web Role Project in solution”

    Add new Web Role

  • In the “Associate with Role Project” dialog select “BCS Web Role” and click “OK”

    Add BCS Web Role

  • Using the same way add “BCS WCF Role”

    Add WCF Web Role

  • When you add both roles to your BCS Azure project it should look like this

    Added web roles

  • Expand “Data Source Library” in the Solution explorer, right click on MSSQLModel.edmx-> “Generate projects with Cloud Meta Man”. Based on the table added to the Entity Data Model, Cloud Meta Man will then go and generate a BCS Listener service project, BCS Caller service project, BCS Web Role project and BCS WCF Role project.

    Generate projects with Cloud Meta Man

  • You will be prompted for Service Namespace Domain(the name you gave the Service Bus instance you created), Issuer Name(the owner) and Issuer Secret(the default key you got once your Service Bus was created). Enter your values and click “OK”. After that the code will be generated.

    Enter Service Bus Namespace Information

  • So now generated projects can be used to test in order to get data through the configured service bus. Build the solution. Select menu “Build”->”Build solution” in Visual Studio

    Build generated solution

  • Let’s take mini steps and test things we created.
    • Right click on the “BCS Listener” project and choose Debug -> Start New Instance

      Run BCS Listener

    • Wait for the successfully established connection

      BCS listener connected to the Service Bus

    • Now right click on the “BCS Caller” project and also choose Debug -> Start New Instance
    • Wait for the successfully established connection

      BCS caller connected to the Service Bus

    • In the Caller console window you should press Enter in order to see a list of departments from your database table! This means the Caller program is calling the GetAll_Department_ReadList method over the Service Bus, and the Listener is executing this method and returning the data back across the Service Bus

      the data returned across the Service Bus

    • The “BCS Caller” application has served it’s purpose. We can now move forward knowing the service bus is working. By pressing Enter we can close only Caller console window.
    • Now let’s test our Azure application locally on the emulator. Right click on the “BCS Azure” project and choose Debug -> Start New Instance. Two browser instances will be launched.
    • First one (BCS Web Role) shows the data is coming through the Service Bus

      The data on the page returned across the Service Bus

    • Second one (BCS WCF Role) shows an error message “403 – Forbidden: Access is denied”. That is correct

      403 - Forbidden: Access is denied

    • If you add to the URL “BCSService.svc” you will be able to see that WCF service was hosted correctly

      WCF service was hosted locally

  • Now we are ready to publish to Azure our application. Lets go to do that.
  • Right click on “BCS Azure” in the solution explorer and choose “Package…”

    Package BCS Azure application

  • Leave the default options and click the Package button

    BCS Azure package configuration

  • Open up www.azure.com and log in. Click on “Hosted Services, Storage Accounts & CDN” on the left pane

    Hosted Services

  • Click on “New Hosted Service” in the ribbon

    Create a new hosted service

  • Give your hosted service a name, url, pick a region, deployment name – and then browse to the BCS Azure.cspkg and ServiceConfiguration.Cloud.cscfg files that Visual Studio created for you as part of the Packaging process ( BCS AzurebinReleaseapp.publish)

    New hosted service configuration

  • The finally click OK. You can accept the warning that is displayed upon clicking OK as this is just a test app, but if it was a real production level app you’d want to take a bit more notice of it.
  • Upon the Hosted Service being deployed and ready we can start testing it!

    Hosted service deployment

  • Let’s take mini steps again and test deployed BCS Web Role.
    • Run “BCS Listener” service at the other end of our service bus. Right click the “BCS Listener” project and choose Debug -> Start new instance. Wait for the successfully established connection.

      BCS listener connected to the Service Bus

    • Run the browser on your PC or smartphone and enter the url you gave your application in Azure. Hopefully you will see something similar to below.

      The data on the page returned across the Service Bus

  • Now let’s fully test BCS WCF Role with SharePoint 2010. Firstly check that our WCF service was hosted correctly in Azure.

    WCF service was hosted on Azure

  • We need to create the External Content Type with CRUD operations exposed by our WCF Service. In order to do it we may use either SharePoint Designer or BCS Meta Man (you may follow one of these articles SPD External Content Type from WCF , WCF Web Service and BCS Meta Man)
  • And voila, we now done it. We created an external list in SharePoint 2010 using a WCF service hosted on Azure and talking to on-premise SQL Server through Azure Service Bus.

    On premise external data are available on SharePoint page across the Service Bus

  • We hope this walkthrough will be useful for you. If you have any questions feel free to email them to support@lightningtools.com

    <Dmitry Kaloshin/>

    Leave a comment