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!


3 thoughts on “Clean AppFabric Databases

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s