Clean AppFabric Databases

When you are developing and testing with AppFabric, you will quickly notice how much the tracked data size grows. as such you will need at times to empty the monitoring and persistence databases and start fresh.

for this there is a great post by Ron Jacobs about how to do just that.

however, here are some minor issues that i faced to make this work. it might help you also.

the powershell script to use is the following:
——————————————————-
import-module applicationserver
$ConfirmPreference = “None”

Remove-ASPersistenceSqlDatabase -Force -Server “.\SQL2008” -Database “AppFabricPersistence”

Initialize-ASPersistenceSqlDatabase -Admins $env:computername\AS_Administrators -Readers $env:computername\AS_Observers -Users “BUILTIN\IIS_IUSRS” -Database “AppFabricPersistence” -Server “.\SQL2008”

Clear-ASMonitoringSqlDatabase -Database “AppFabricMonitoring” -Server “.\SQL2008”
—————————————————

where AppFabricPersistence and AppFabricMonitoring are the database names i used when configuring AppFabric. while SQL2008 is my SQL named instance where AppFabric is configured.

Save this text into a “.ps1” file and take care to remove line breaks. meaning that you will have a total of four lines. if you don’t you will get script execution errors when later you run the script.

now when you run powershell, make sure to do so in admin mode. in addition run the one called Windows Powershell and not Windows Powershell (x86). if you run the X86 verison you will get an error that module “applicationserver” cannot be loaded when you try to run the script. note that my setup was on Windows 7 64-bit.

we are still not done, again now if you try to run the script in powershell by typing [filename].ps1 you will get an error “.ps1 is not recognized as the name of a cmdlet, function, script file, or operable program…”.
to solve this type “.\[filename].ps1”

Finally, when you run the script you might get an error that “the execution of scripts is disabled on this system”. you need to enable script execution for powershell. for this run command “set-executionpolicy unrestricted” for allowing all scripts. another key values might be “Restricted”, “AllSigned”, and “RemoteSigned”.

again i point that my environment was win 7 64-bit, so in another environment there could be some differences…but anyway…

this should be enough then to run the script and watch your AppFabric dashboard clean again!

A Common Question: Concurrency vs Parallelism

While presenting a .NET 4.0 session in GDC, i came across Parallel Computing. I allocated about 15 minutes to this topic since the session was a lap around .NET 4.0 features…
One of the questions I received and seemed to cause much of the confusion was the traditional one: What is the difference between Concurrency and Parallelism.

Well both concepts are related but not the same: In its simplest definition, Concurrency is about executing multiple un-related tasks in a concurrent mode. What these un-related tasks share are system resources, but they do not share a common problem to solve; meaning, they are logically independent. Now think of these tasks as threads. And since these threads share system resources, then you face the globally common problems of concurrent programming such as deadlocks and data races. This makes concurrent programming extremely difficult and debugging even more tendous.

So what is Parallelim? Parallelism is taking a certain task and dividing it into a set of realted tasks to be executed concurrently. Sweet! So again thinking of these tasks as threads, Parallel Programming still has the same problems of concurrent programming (deadlocks, data races, etc..) and introduces new challenges most notibly sharing and partitioning data across these related threads. This makes Parallel Programming even more difficult and debugging even more tendous 😦

However, it is not all bad news. .NET 4.0 parallel programming is a great step onwards. The new API solves a lot of problems (but not all) of Parallel Programming and greatly eases up Parallel Debugging…

I will post more about this great feature, but for now I hope the idea is clarified.

Azure Service Bus Lab: ContractFilter Mismatch Error

If you are following the Windows Azure (November CTP) SDK, and you are implementing the .NET Service Bus (AppFabric) Hands on lab called “Introduction to the .NET Service Bus”, then there is an error that you need to correct.

In task 4 titled “Task 4 – Creating the WCF Client Project “, the lab says that you create an interface IEchoContract and apply to it the following attribute:

[ServiceContract(Name = “EchoContract”, Namespace = “http://samples.microsoft.com/ServiceModel/Relay/”)]

Well the Name is wrong. if you have followed the lab manual precisely, then the Name should be “IEchoContract” instead.

If you run the sample without correcting the issue, you will be faced with the following exception:

The message with Action ‘http://samples.microsoft.com/ServiceModel/Relay/’ cannot be processed at the receiver, due to a ContractFilter mismatch at the EndpointDispatcher. This may be because of either a contract mismatch (mismatched Actions between sender and receiver) or a binding/security mismatch between the sender and the receiver. Check that sender and receiver have the same contract and the same binding (including security requirements, e.g. Message, Transport, None).”

This problem can also appear if the namespace is different between the client and the service, so make sure to use the same namespace

SQL Azure Object Browser Support in SQL Server 2008

If you are playing with the Azure training kit (November update) and you come across the lab about setting up SQL Azure, then you need to notice one thing:

the lab shows you how to connect to the cloud database using SQL Server 2008 R2 and thus you will get the Object Browser support.

However, the object browser is not supported in SQL Server 2008 pre-R2. So if you follow the steps without having R2 you will end up with an error message saying:
“Invalid Object name sys.configurations”.
The reason is that the Management Studio cannot load the Object Browser from SQL Azure simply because it is not supported yet (again for pre-2008 R2 releases).

So the only way to connect to your SQL Azure database is through the “New Query” link in the Management Studio. This will give you full connectivity but without the Object Browser, so you will have to rely on your DDL skills to manage your db objects.

Activating Azure Storage Service for Non SQL Express

I recently installed the November release of the Azure SDK.

I created a sample Web Role application and tried to run it, but I got the below error:

“Windows Azure Tools: Failed to initialize the Development Storage service. Unable to start Development Storage. Failed to start Development Storage: the SQL Server instance ‘localhost\SQLExpress’ could not be found. Please configure the SQL Server instance for Development Storage using the ‘DSInit’ utility in the Windows Azure SDK.”

Under default configurations, the SDK will point your storage service into SQL Server express instance.
Well in my case I did not have Express, instead I had SQL Server 2008 Dev Edition.

So to resolve this, go to the “Windows Azure SDK Command Prompt” and run the following command:
DSInit /sqlInstance:. /forceCreate

This will create your storage database under the default instance. Of course you will have to supply the named instance in case you have one. For example:

DSInit /sqlInstance:MyNamedInstance