Setup source code locally

Use Visual Studio 2008 sp1 or Visual Studio 2010 Beta2 and above
1. Download source code
2. Install windows azure SDK
3. Add the following to C:\Windows\System32\drivers\etc\hosts
127.0.0.1 test.xinqiu.com
We need this also for kml file display from live map service

The corresponding code is inside Global.asax file, to redirect localhost to use the above mapped url.

protected void Application_BeginRequest(object sender, EventArgs e)
{
#if DEBUG
if (Request.Headers["Host"].Split(':')[0] == "localhost")
{
Response.Redirect(
Request.Url.Scheme
+ "://"
+ "test.xinqiu.com"
+ ":" + Request.Url.Port.ToString()
+ Request.Url.PathAndQuery
, true);
}
else if (Request.Headers["Host"].Split(':')[0] == "127.0.0.1")
{
Response.Redirect(
Request.Url.Scheme
+ "://"
+ "test.xinqiu.com"
+ ":" + Request.Url.Port.ToString()
+ Request.Url.PathAndQuery
, true);
}
#endif
}
4. The project's own SQL express mdf file contains only a few cities, to get all the cities and populated regions in the world, you may want to create an empty mdf file to replace the existing one, and do the following:
a. Install web deploy http://www.iis.net/expand/WebDeploymentTool (Or installed by Visual Studio 2010 automatically)
b. Use the command line like following inside SetupDatabase\FullDBSetup directory to populate your own database.
SetupFullDB.cmd SetupFullDB.cmd "Data Source=.\SQLEXPRESS;AttachDbFilename=F:\Myprojects\MapWayCodePlex\WebRole1\App_Data\LocationsDB.mdf;Integrated Security=True;User Instance=True;"

SQL Azure deploy

1. Get SQL Azure account, setup a database, make sure firewall exception is set for both Microsoft service and your own IP address

You may want to create a new user for your SQL Azure database, such as following:

In master database:
CREATE LOGIN myLogin1 WITH password='myLogin1Pwd';

In LocationsDB database:
CREATE USER myUser1 FROM LOGIN myLogin1;
GRANT ALTER to myUser1;
GRANT SELECT ON SCHEMA::[dbo] TO [myUser1];
GRANT INSERT ON SCHEMA::[dbo] TO [myUser1];
GRANT DELETE ON SCHEMA::[dbo] TO [myUser1];
GRANT UPDATE ON SCHEMA::[dbo] TO [myUser1];

--EXEC sp_addrolemember 'dbmanager', 'myUser1';
--EXEC sp_addrolemember 'loginmanager', 'myUser1';



2. Install web deploy http://www.iis.net/expand/WebDeploymentTool (Or installed by Visual Studio 2010 automatically)
3. Use the command line inside SetupDatabase\FullDBSetup directory:
SetupFullDB.cmd "Server=tcp:SQLAZUREDBNAME.database.windows.net;Database=LocationsDB;User ID=USERNAME;Password=PASSSWORD;Trusted_Connection=False;Encrypt=True;"
Note: this may take a long time (8 hours, as we have 180,000 + city data to load. Also, my last try showed the last file failed to upload by msdeploy. As a workaround, please execute the last file via Microsoft SQL Server Management Studio.

Windows Azure dpeloy

1. Change Web.config web authrization handler deploy secrete key
Get your own application ID and secret Key for Windows Live ID web authentication
http://msdn.microsoft.com/en-us/library/bb676626.aspx

Application ID: 000000004802A138
Domain(s): test.xinqiu.com
Return URL: http://test.xinqiu.com:39694/webauth-handler.aspx
Secret Key: ErYjfT1aGTz58L6AKr9us6zm8xfozzxi
2. Change the connection string to something like following (use your own SQL Azure username and password pair)
//sql azure
<add name="LocationsDBEntities" connectionString="metadata=res://*/DataService.LocationsDB.csdl|res://*/DataService.LocationsDB.ssdl|res://*/DataService.LocationsDB.msl;provider=System.Data.SqlClient;provider connection string=&quot;Server=tcp:DATABASENAME.database.windows.net;Database=LocationsDB;User ID=USERNAME;Password=PASSWORD;Trusted_Connection=False;Encrypt=True;MultipleActiveResultSets=False&quot;" providerName="System.Data.EntityClient" />
3. Follow Windows Azure deploy step

Last edited Mar 15, 2010 at 4:58 PM by xinqiu, version 2

Comments

No comments yet.