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.
- 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
- Then click on the Service Bus node that is displayed in the tree
- Create a new Service Namespace – type a Namespace name, pick a country and the subscription.
- 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
- Click on the button to view the Default Key, you’ll need these details shortly
- 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”
- In the Solution explorer right-click on the “Data Source Library” node, select “Add”->”New Item”
- 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”
- In the “Entity Data Model Wizard” select “Generate from Database” and click “Next”
- On the next step click “New Connection” or use existing one
- 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”
- Now click “Next”
- Select one object you want to include to the model. For example “Department” table and click “Finish”
- Your diagram should look like this
- Expand “BCS Azure” project in the Solution explorer, right-click on “Roles” folder, select “Add”->“Web Role Project in solution”
- In the “Associate with Role Project” dialog select “BCS Web Role” and click “OK”
- Using the same way add “BCS WCF Role”
- When you add both roles to your BCS Azure project it should look like this
- 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.
- 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.
- 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
- Let’s take mini steps and test things we created.
- Right click on the “BCS Listener” project and choose Debug -> Start New Instance
- Wait for the successfully established connection
- Now right click on the “BCS Caller” project and also choose Debug -> Start New Instance
- Wait for the successfully established connection
- 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 “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
- Second one (BCS WCF Role) shows an error message “403 – Forbidden: Access is denied”. That is correct
- If you add to the URL “BCSService.svc” you will be able to see that WCF service was hosted correctly
- 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…”
- Leave the default options and click the Package button
- Open up www.azure.com and log in. Click on “Hosted Services, Storage Accounts & CDN” on the left pane
- Click on “New Hosted Service” in the ribbon
- 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) - 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!
- 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.
- 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.
- Now let’s fully test BCS WCF Role with SharePoint 2010. Firstly check that our WCF service was hosted correctly in 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.
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/>
Good way. Now a day, no need to go out of the internet because Internet itself showing many different and unknown information to us. Today I have got an useful information from your blog…