Nov 23, 2012

I came accross an issue today where I wanted to deploy a .NET 4.5 (osVersion=”3”) cloud service using a self-signed SSL certificate to protect the web service traffic:

11:55:44 AM - Preparing deployment for <solution> - 11/23/2012 11:55:30 AM with Subscription ID ‘<subscription>' using Service Management URL 'https://management.core.windows.net/'... 11:55:44 - Connecting... 11:55:46 - Warning: Error: Certificate: ‘SSLCertificate’ with Thumbprint: <thumbprint> for Role: <solution>Service has not been uploaded to the cloud service: <solution>. 11:55:46 - The deployment cannot be completed because it requires certificates or OS images which are not present in the cloud. 11:55:46 - Deployment failed with a fatal error

I investigated around my projects certificate settings, thumbprint or certificate store location – in vain. Then I solved the problem:

Go to the Azure portal and upload the pfx file directly into your cloud service (certificate tab)

After this manual upload the deployment will succeed

NOTE

Looks like this being by design: conforming to some best security practices where developers should not have access to the production certificates – so deployment stops here. Took me some time so see it – but is perfectly true.

Jan 30, 2012

I got a SQL server (express) database backup (.bak file) from a customer to do a test against. In the past, I just restored from my own, previously existing databases, so I never came across the issue of restoring one from a complete different machine. Using SSMS I got the following error messages

The backup set holds a backup of a database other than the existing database – or

File 'Db' cannot be restored to 'C:\Program Files\Microsoft SQL Server\MSSQL10_50.CUSTOMER\MSSQL\DATA\Db.mdf'. Use WITH MOVE to identify a valid location for the file.

The path does not exist on my machine. After browsing the web I found out the following:

create a new and empty database named as the one from the customer (in this case ‘Db’)

Jan 29, 2012

This year the ESE conference 2012 will take place in Zurich April 24. and 25. – hosted by Zühlke Engineering AG.

That’s where software experts from around the world meet their peers and prominent speakers. The conference targets software architects, project managers, IT manager, process experts and all kinds of techies. Interactive discussion and talks are a major part of the two days.

There are three trendy tracks: Agile, Cloud and Mobile. See this for more details.

Using Windows “Azure Connect” - a service from the Windows Azure platform – one can establish a protected network connection between enterprise computers and the cloud roles (E2C). This virtual IPsec network allows for:

easier migration of tiers of an applications to the cloud

tunnel firewalls, proxies, NATs

hybrid (cloud to on-premise) apps

various higher-level communication protocols

apps where the protocol might change

have high number of communicating endpoints

domain joins (some ActiveDirectory; logins)

remote administration, debugging and troubleshooting

DNS

etc.

Setting up Connect is a 3 step process. There is a tutorial showing all the details.

1. Get an activation token from the Azure portal and configure your Azure roles to use it.

Copy the token into your role’s properties / virtual network settings

Now you publish your Azure roles to the staging or production environment in the cloud. Wait until the service is ready and check that it appears in the portals “Virtual network” –> “Groups and Roles” and “Activated Endpoints”.

2. Enable local machines to connect to roles in the cloud. Install the Connect Agent on local machines. Copy the link URL to a browser, download the configured executable and run it. A system tray icon like the following should appear

3. Pair the local machines and Azure roles in a “Group” (network policy). In the portal click Create Group

The system tray icon should change to connected now.

Please note that ping will not work until you enable it in your role using a startup task script. From my limited home network I experienced some significant (first-hit) network delays

Azure Data Sync let’s you synchronize enterprise (on-premise) SQL Server (2005 and above) databases with SQL Azure databases – or several SQL Azure databases. There is a local agent and a cloud sync group service necessary for it to work.

Now generate an agent key from the management portal and copy it into the local agent wizard.

Then register a SQL Server

to get

Back in the portal we add the agent to the Sync Group

Now we are half way through. Now let’s add an SQL Azure database:

Just creating a new SQL Azure database for this demo – and selecting it in Step 3 above.

In the following step (4) we configure the scheduling, and the conflict resolution (client or hub wins)

Select the on-premise SQL database

Click deploy now

Done!

Now, let’s see that it worked correctly. In the local Northwind database there are 2 people from Switzerland, add a row filter for Country = ‘Switzerland’. Then go the SSMS, connect the SQL Azure DB. There is a new dbo.Customers table now. Please also note the added tables for the change tracking. There are also some triggers and stored procedures added to your database. This may impact your runtime performance.

There are the 2 rows as expected:

That’s it again in the portal

This was actually super simple to setup. There are some best practices out there.

Negative point: there does not seem to exist an API or .NET library for scripted configuration and operation.

Requirements

R-U1 – Create an online account on the site R-U2 – Log in and out R-U3 – Choose a treatment R-U4 – Choose a time/date R-U5 – Book a massage R-U6 – Got sent an email confirmation R-U6.1 with an outlook appointment attached to it R-U7 – get shown my booked treatments in detail

New Web Project

To separate DotNetNuke module stuff from booking web functionality I added a new ASP.NET web project to the solution

remove the generated pages, sub folders and strip down the web.config file to a minimum.

Now add a web user control to the BookingViews project

Telerik

Writing an outlook style schedule/calendar control in ASP.NET seems like a huge effort. Let’s get a commercial control library suite including a schedule control. As DNN already contains Telerik controls the evaluation was short. They have an excellent reputation when talking to colleagues.

Data Model

First let’s show the data access layer where the massage bookings and treatment offerings are persisted. Using the Entity Framework 4.0 model first approach, I create the following model:

The BookingEntry and Treatment entities were added in the model edmx in VS design view. However, the User entity was imported from the existing DotNetNuke database (table first). Adding some relations and I can take advantage of the DNN register/login/user functionality in my bookings.

View

Learning and configuring the module view took more effort. This is the resulting aspx:

The control’s data sources are of type ObjectDataSource. BookingEntryDataSource and TreatmentDataSource both implement the IRepository<T> interface. This hides the EF stuff behind a façade and allowed better testability than the EntityDataSource:

///<summary>

/// Interface to decouple entities from data access.

///</summary>

publicinterfaceIRepository<T> where T: class

{

void Add(T entity);

void Delete(T entity);

ICollection<T> GetAll();

T GetById(T entryWithKeyOnly);

void Update(T entity);

}

Note that I added the telerik rad scheduler, configured a week view, added some appointment resources and DataSources to be bound in the scheduler control.

And this is the final result:

Double clicking shows or edits the details of the appointment

I hope this 3-part series of my (hobby project) development “minutes” gave you some insight around DotNetNuke module development in Visual Studio using C#.