Forms-Based Authentication with SQL Azure


Following is quite useful

I was able to get this to work without a Windows Azure Project

Worked on site. However the role manager did not wok

Changed following and it worked
<roleManager enabled=”true”>




Deleting an ASP.Net azure hosted website using Entity Framework can potentially delete the linked database

I had a database on Azure that was being updated using Windows Forms. I then created an ASP.Net MVC application using EF to work against the same database. However I following a tutorial which used Code First

This would not publish until I used Nu-Get to:


However I think I then used code first migrations on publish. However I published the website with high credentials and wanted to change the credentials to lower. Could not see how to do this in Azure, so deleted the website. At this point the database disappeared without warning.

This is why the last posts have been about SQL Azure backup. However recovered using on-site data and re-created database.

Microsoft support helped with the ASP.Net so:


Check the file created, but do not check the box on publish.

Tested by deleting the Website – This then asked if you wanted to delete the linked database. Answer: No. Database stays ok.

How do I backup SQL Azure to a Blob Storage Account using bacpac

My word press blog entry


How do I … backup by using Create Database … As Copy Of to an Azure database (to Azure)

–Start logged into Azure and with master as current database
–Does work 27/06/2012

–Must wait for state to be changed from Copying to ?Ready?
SELECT * FROM sys.dm_database_copies
SELECT * FROM sys.databases
SELECT name, state, state_desc from sys.databases where name = ‘_20120627’

–Test that data is there

Azure Storage – a pre-requisite to export SQL to blob storage

A storage account needs a container before it can be used.
The container may be made in Visual Studio using a new Project > Cloud > Windows Azure Cloud Service
When this project is created with any Web Roles you create the relevant projects will also be created and linked.
When this is created make this Cloud Service Project the start-up project and run-it in Visual Studio as an administrator you may then get further, it will not start the cloud service project but the web project. This will then give relevant keys.

I found this not to run in local. Needed to publish it first.
Then in Azure Management > Hosted Services > Locate > Run from DNS


To test the application in the staging environment

  1. From the portal, in the left pane, click Hosted Services.
  2. In the middle pane, expand GolferMessageBoard, and then click v1.2.0.0.
  3. In the Properties pane, click the URL in the DNS name box. The application is opened in a new browser tab or a new browser window depending on your browser configuration.
  4. Test the application by entering one or more entries.

After the application is working correctly in the staging environment, you are ready to promote it to the production environment.

To promote the application to production

  1. From the portal, in the left pane, click Hosted Services.
  2. In the middle pane, expand GolferMessageBoard, and then click v1.2.0.0.
  3. From the top menu, click Swap VIP.
  4. In the Swap VIPs dialog, click OK. Wait until the Status for the deployment changes to Ready.
  5. In the Properties pane, click the URL in the DNS name box. The application is opened in a new browser tab or a new browser window depending on your browser configuration.
  6. Test the application in the production environment by entering one or more entries.


Azure Export of SQL database to blob

The format of the file should be
http:// teststorage01.blob.

I had following error:
“azure blob is not writeable … the specified container does not exist”

To create the container make sure the above has been published to Azure and run from there.


How do I … change Config ConnectionString at runtime

See code below

Public Class RuntimeConnection

Const ConStringSettingsName = "MyEntitiesName"

Sub SetRuntimeConnection(UserNameValue As String, PasswordValue As String)
Dim currentConString = ConfigurationManager.ConnectionStrings(ConStringSettingsName).ConnectionString
Dim myWebConfig = System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration("~")
Dim builder As New EntityClient.EntityConnectionStringBuilder(currentConString)
Dim sqlConStrManager As New SqlClient.SqlConnectionStringBuilder(builder.ProviderConnectionString)
sqlConStrManager.UserID = UserNameValue
sqlConStrManager.Password = PasswordValue
builder.ProviderConnectionString = sqlConStrManager.ConnectionString
myWebConfig.ConnectionStrings.ConnectionStrings(ConStringSettingsName).ConnectionString = builder.ConnectionString
'Dim msg = String.Concat(sqlConStrManager.ConnectionString, vbCrLf, vbCrLf, builder.ConnectionString, vbCrLf, vbCrLf, _
' myWebConfig.ConnectionStrings.ConnectionStrings(ConStringSettingsName).ConnectionString)
End Sub

End Class

Also see below

Imports System.Configuration


Dim config As Configuration = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None)
config.ConnectionStrings.ConnectionStrings("myEntities").ConnectionString = value




ASP.Net publish to Azure with Database and control of Start Page


There was a warning on publish page 3, which mentioned code-first migrations must be enabled. After web-search I realised I needed to upgrade to a higher version of EntityFramework which has System.Data.Entity.Migrations

Used Visual Studio > Tools > Library Package Manager > Package Manager Console

PM> install-package EntityFramework -Pre

PM> enable-migrations

will then publish. Although now up, the sites page is “This web site has been successfully created. There’s nothing here yet, but Windows Azure makes it simple to publish content with GIT, TFS, FTS or your favorite development tool”

If go directly to a page I know exists it does take me there, (or in my case redirects to login)

During development this of course wasn’t an issue – I just right clicked the page I wanted as startpage as selected “Set as Start Page”.

When I deployed to Azure the start page wasn’t recognized. To set the start page in Azure it is necessary to do one of two things: 1) Implement a start page called “Default.aspx” or 2) specify the start page in the web.config file:


Setting the defaultDocument value in the web.config fixed my issue.



ASP.Net Forms Authorization



to add authorisation schema to an existing database

This will not work with SQL Azure. See

which links to

ASP.Net MVC VB.Net Troubleshooting


The connection name ‘ApplicationServices’ was not found in the applications configuration or the connection string is empty


Go to Project level web.config. Find <membership> change connectionStringName=”ApplicationServices” to “LocalSqlServer”


How do I … ASP.Net MVC with VB.Net

How do I … submit text from an input box.

    <form action="" method="post">
   Code starts with: <input type="text" name="MinCode" id="CodeInput" />
    <input type="submit" value="Click Me" /> 


    <form id="search" action="" method="GET"> 
    <input type="text" name="q" /> 
    <input type="submit" value="Submit" /> 

How do I … Register Routes

 routes.MapRoute("Products", "Products/{myCode}", _
              New With {.controller = "Products", .action = "Search"})

How do I … use this route in a controller

        Function Search(name As String) As ActionResult

            Dim myName = RouteData.Values("name")
            Dim myNameFromSignature = name
            Dim result = String.Concat(myName, vbCrLf, name)
            'Return RedirectToAction("Index")
            Dim model As New List(Of ProductsModel)
            model = model.Where(Function(f) f.Code.ToLower.StartsWith(name)).ToList
            If model.Count = 0 Then
                Return Content(Server.HtmlEncode("No results"))
            End If

            'ViewBag.Name = name
            Return View(model)

        End Function

How do I now call this ASP.Net MVC Search Box

<% Html.BeginForm("Search", "Products")%> 
   <input type="text" name="myCode" /> 
   <input type="submit" name="Submit" /> 
<% Html.EndForm() %>

Confirmed that this works. SRS 18/06/2012. Then did not work 19/06/2012. However following did work.

this example also includes “How do I use @ in ASP.Net MVC including Using.

@Using (Html.BeginForm(“Search”, “Reg90″, FormMethod.Post))
@:<input type=”text” name=”myCode” />
@:<input type=”submit” value=”Click Me 2″ />
End Using