One of the things I’ve been playing with lately is SQL Azure. I’ll post about my experience using Windows Azure and SQL Azure together shortly, this post is all about setting up SQL Server Management Studio (SSMS) with SQL Server Express 2008.
In order to use SSMS with SQL Azure, you need to have the 2008 version of SSMS installed. I had the 2005 version and it failed to connect.
The reason I’m posting about this is that I ran into a few non obvious things. Now the thing is, I’m not that savvy with SQL Server and I’m sure that contributed to my confusion. On the other hand, I figure other folks may be in my situation and could find this to be useful – if I can save a couple of people’s time, then I’m happy :)
From what I understand, because there are so many different SQL Server installs and because how you install SQL Server can also impact how you can add or even if you need to add SSMS, this set of instructions is far from complete.
If my scenario below is different for you, I found a lot of good information in the comments of this article. You just have to sort through them and figure out what all the options/dialogs everyone is talking about.
Back to my scenario -- I specifically had SQL Server Express installed through my Visual Studio installation and I wanted to add SSMS.
There are two ways I can get SSMS for SQL Server Express 2008, one is with a download of SQL Server 2008 Express that includes SSMS, the other is through the standalone installer.
Because i already had SQL Server Express 2008 installed, I downloaded and ran the standalone installer. Upon running, I received this dialog:
Which scared me into thinking that I didn’t have SP1 of SQL Server installed. Turned out I had so I could safely ignore this dialog. Key point here is not to let this dialog mislead you.
Upon hitting “Run”, I was brought to the SQL Server Installation Center:
Again I’ll remind you that I’m not much of a SQL Server guy, so I really had no idea what to do next. I expected to just click next through a bunch of installer screens then go to my start menu and find SSMS – so what is this I see?
After some experimentation and trial and error (too much trial and error in fact), I found I needed to click the “Installation” link on the left then click the “New SQL Server stand-alone installation or add features to an existing installation” link.
Great, after hitting next through some setup files, a rule check and a EULA, I was brought to the following dialog:
Here I initially chose to “add features” – seems like that would make sense but it turned out to be a dead end.
I went back to “Perform a new installation of SQL Server 2008” and that led me to the next screen which allowed me to select “Management Tools – Basic”. This is the one you want to select. (it’s already selected in the screen shot below because SSMS was installed at the time of this screen shot).
After clicking through the remaining dialog, I was happy to see SSMS under my start menu, Microsoft SQL Server 2008 folder.
Now I can connect to SQL Azure through the Query editor (not the connect dialog that comes up when you start SSMS or from the object explorer). Only a connection from the Query Editor is supported. (a later version of SSMS, for SQL Server 2008 R2 is coming that will support SQL Azure)
More to come on my SQL Azure + Windows Azure experience soon.
Hope this was helpful for someone.
Here’s a fun little thing I found out about recently. Suppose, I have a Cloud Service that I’m running on the devfabric and I want to simulate a configuration change.
I’ll start by creating a cloud service with a single web role:
Opening the service configuration file, I can see that the instance count is set to 1.
<Instances count="1" />
I hit F5 and my service has 1 instance of the web role running on the devfabric:
Note that the deployment ID is 51 – it’s in brackets in deployment(51).
To change the configuration while my apps is running, I open up the Windows Azure SDK command prompt (found in the start menu) and navigate to where I created my cloud service. An easy way to get there is to right click on the Cloud Service node in Solution Explorer and select “Open Folder in Windows Explorer”.
In that directory will be a ServiceConfiguration.cscfg file. This corresponds to the file in your cloud service project. Edit the value of your ServiceConfiguration.cscfg file (the one you edited before) and change the instance count to 3.
<Instances count="3" />
Now use the command line tools csrun to update the service configuration file. The command line help shows the command is:
You’ll remember above that in my case the deployment ID was 51. So my command will be:
> csrun /update:51;ServiceConfiguration.cscfg
csrun will then tell me that the new settings have been updated and when I look at the devfabric UI again, I hit refresh and I see that there are now 3 instances of the Web Role.
There are a couple of tricks here – because we are debugging this service, we started the role instances as suspended. Click on the Service Deployment, in my case deployment(51) and hit the play button to get those instances to run.
What you’ll also notice now is that if you hit “break all” in VS to stop in the debugger, VS is still only debugging one instance of RdRoleHost.exe which is the host process for the web role.
To debug the new web role instances while not stopping this session, go to the VS Debug menu and select “Attach to Process” and select the RdRoleHost.exe processes that are not currently being debugged and click “Attach”.
Hit “run” and now you’re debugging all of the role instances after making the configuration change.
Alright, I admit – a bit of a party trick to impress your friends with (now I have you guessing what kind of parties I go to) and not terribly useful in the July CTP as the role instances restart when the service configuration file changes. You may also see some cases where the dfagent crashes (these are not the droids you are looking for).
Letting the cat out of the bag here – in the upcoming release, you will have more control over what happens with your roles after a configuration change and it may be interesting to debug this scenario.
In case you didn't see this on Ryan Dunn's blog, we just released some neat Powershell cmdlets that wrap the Service Management API and allow you to script your deployments, upgrades and most of what you can do today in the Developer Portal.
They are available here:http://code.msdn.microsoft.com/azurecmdlets
The csmanage tool that utilizes the Service Management API may also be of interest to you: http://code.msdn.microsoft.com/windowsazuresamples
I generally don’t like to just make announcements like this on my blog but since it is very Windows Azure developer tool related, I wanted to include it.
Recently, I updated a somewhat out of context (for this blog) post titled "Windows Azure Tools and Visual Studio 2010”.
One of the things you’ll notice is that we let the cat out of the bag that we’ll be releasing something new and big in November! (ok, maybe not a big surprise given that PDC 2009 is in November as well)
It’s one of the reasons my blog has been quieter than usual over the last months, there’s a lot of stuff coming and I’ll have a lot of posts in November and December.
That said, the main reason for the post is to provide a landing page for a link we have from Visual Studio 2010. In fact, we have a lot of cool Visual Studio 2010 integration features to talk about.
Let me elaborate.
When you first start up Visual Studio 2010 beta 2, you’ll see in the “Getting Started” tab that there is a section for “Cloud”. Here you can get directed to a lot relevant content for developing for Windows Azure, notably a number of links to the newly redesigned azure.com.
When you click on File –> New Project, you’ll also see that by default (no tools installed), we have a node under Visual Basic and Visual C# entitled “Cloud Service”.
When you select that node, you’ll see the following – a project template called “Enable Windows Azure Tools”
When you create that project VS will open up a page with the following:
Here, you can click on “Download Windows Azure Tools” to get the latest tools for Visual Studio.
Today – it will take you to the page I mentioned above – we’re getting our exciting upcoming release ready for you!
From my previous post:
We’re really excited about this release as not only does it support Visual Studio 2010 Beta 2, but it also adds a new UI over the service definition and configuration files, adds new template options for creating roles, improves debugging integration with the development fabric and integrates with a number of new platform features and improvements.
We’re really excited about this release as not only does it support Visual Studio 2010 Beta 2, but it also adds a new UI over the service definition and configuration files, adds new template options for creating roles, improves debugging integration with the development fabric and integrates with a number of new platform features and improvements.
Windows Azure Tools for Visual Studio
Windows Azure Tools for Microsoft Visual Studio extend Visual Studio to enable the creation, building, configuring, debugging, running and packaging of scalable web applications and services on Windows Azure.
Windows Azure Tools for Visual Studio 2010 Beta 2 – Coming Soon!
We’re putting the final touches on our upcoming November release of the Windows Azure Tools, SDK and cloud which will support Visual Studio 2010 Beta 2.
Please check back regularly for availability. In the meantime, if you have Visual Studio 2008, you can use the Microsoft Web Platform Installer 2.0 to get the Windows Azure Tools for Microsoft Visual Studio 2008.
You can also learn more about Windows Azure at http://azure.com.
Today, the IIS team released a the Web Platform Installer 2.0 RTW. Among the many cool new things (more tools, new applications, and localization to 9 languages) is the inclusion of the Windows Azure Tools for Microsoft Visual Studio 2008.
Install the Windows Azure Tools for Microsoft Visual Studio 2008 using the Web Platform Installer.
Why should you care? As many of you know, before using the Windows Azure Tools, you need install and configure IIS which requires figuring out how to do that and following multiple steps. The Web Platform Installer (we call it the WebPI) makes installing the Tools, SDK and IIS as simple as clicking a few buttons.
For example, on a fresh machine, when I use the WebPI to install the Tools – look at all of the dependencies that get brought in and installed for me. I also don’t need to know to install IIS as a separate step, *it just works*.
One thing I do want to point out is that if you to browse around the WebPI to find the Windows Azure Tools, you first have to go to the Options dialog:
And select the “Developer Tools” checkbox.
A couple of other notes:
Today, the WCF team released a patch that will help you if your are using WCF on Windows Azure.
Essentially, if you use the "Add Service Reference..." feature in Visual Studio or svutil to generate WSDL for a service that is hosted on Windows Azure either locally or in the cloud, the WSDL would contain incorrect URIs.
The problem has to do with the fact that in a load balanced scenario like Windows Azure, there are ports that are used internally (behind the load balancer) and ports that are used externally (i.e. internet facing). The internal ports were showing up in the URIs.
Also note that this patch is not yet in the cloud, but will be soon. i.e. it will only help you in the Development Fabric scenario for now. (Will post when the patch is available in the cloud.)
While we're on the topic of patches, please see the list of patches related to Windows Azure.
In the July 2009 CTP of the Windows Azure Tools for Microsoft Visual Studio, we introduced a bug where if you use the App.Config file in a Worker Role, it won’t get included in your Service Package both when running on the local Development Fabric or in the Cloud.
To resolve this issue, simply add the following environment variable before starting Visual Studio:
This will be fixed in our next release, in fact it’s fixed in our daily builds already.
In order to support TFS Build, we changed how files are copied to the package for the Worker Role. As part of the changes, we missed calling one of the targets with a property set to handle the App Config.
It was lucky for us that our customers can workaround the issue by setting the environment variable above and MSBuild will do the right thing.
To elaborate on the scenario, if you create a new Cloud Service with a Worker role by clicking File | New Project | Visual C# | Cloud Service and adding a Worker Role:
Right Click on the WorkerRole1 project in Solution Explorer and select Add | New Item and select the “Application Configuration File” item.
Build the solution and navigate to the Service Package (more info on Service Packages) and you’ll find that the app.config file is missing from the worker role. (no WorkerRole1.dll.config)
This is true in the packaging for the Development Fabric and if you Published for the Cloud.
Exit Visual Studio and add the environment variable: AddAppConfigToBuildOutputs=true
Then restart Visual Studio and open up that same solution you were working on.
Rebuild All and again navigate to the Service Package. This time you will see the WorkerRole1.dll.config file as you would expect.
Sorry for the inconvenience, again this is temporary and you now know the workaround.
Some forum threads about this:
After you install the July 2009 CTP and create a new project via File | New Project | Cloud Service, you now have a single template “Cloud Service” instead of the 4 you had in the past.
Clicking on that brings up our new project creation dialog.
There are a couple of reasons we have this dialog:
You can add Web and Worker Roles to the Cloud Service solution, rename the projects and hit OK to create the Cloud Service. Try adding 2 Web Roles and 2 Worker Roles.
You’ll have a solution that matches:
Note that you’ll want to setup the port numbers for your input endpoints in the ServiceDefinition.csdef.
We auto-generate what we hope to be safe numbers but don’t know what your intention is for each of the Web Roles – at this point in time, a second or third Web Role cannot be assigned to a sub domain, they can only be differentiated by port.
When you hit F5, we’ll bring up a web browser instance for each of the Web Roles.
If you don’t want us to bring up a Web Browser instance for a given web role, right click on the associated Role under the Roles node and deselect “Launch Browser”.
Also note that when you close one web browser, your debugging session will end.
I’m pleased to announce that we have released a new version of the Windows Azure Tools and SDK! (will take time to propogate, try the direct link to the download)
What’s New for the July 2009 CTP?
“Enhanced robustness and stability” means that we fixed some issues we’ve heard from customer feedback:
For more information on using the new features, please see the following posts:
Working with Multiple Web and Worker Roles
Associating an ASP.NET Web Application (including MVC) as a Web Role
For more recent information on using ASP.NET MVC with Windows Azure please see this post.
If you’ve been following along, you’ll remember my post about using an existing ASP.NET Web Application as a Web Role. We’re now a little smarter in the tools and can allow you to associate any ASP.NET Web Application in the Cloud Service as a Web Role.
For example, I can create a Cloud Service with just a Worker role, right click on the Solution in Solution Explorer and select Add | New Project and select an ASP.NET Web Application from the Web folder.
This could be *any* ASP.NET Web Application, including derivatives of it like an MVC project, Dynamic Data etc.
For the sake of this demo, I’ll add an ASP.NET MVC Web Application:
I then right click on the Roles node in the Cloud Service project and select Add | Web Role Project in solution…
Now instead of just “Web Roles”, you will get a list of all ASP.NET Web Application project types. In this case, I select the MVC Web Application I created:
And there you have it, you are using a new or existing ASP.NET Web Application as a Web Role.
(Note that if you want to use the Service Hosting runtime APIs, you’ll have to add a reference to Microsoft.ServiceHosting.ServiceRuntime.dll yourself.)
When I hit F5, I get the behavior I expect, the MVC Application running on the Windows Azure Development Fabric.
One additional note: in order for the MVC assemblies to be included in your service package that you will upload to the cloud, make sure you set the copy local property to true for the MVC DLLs (More information here):
We hope this will make using different application types (like MVC, Dynamic Data and others) as well as using your existing ASP.NET applications easier. Let me know what you think!
Many of you may not even know this, but as part of the Windows Azure Tools for Microsoft Visual Studio, we ship a Role template called “CGI Web Role”.
Today, it’s a little hard to find (yes, I’m foreshadowing that this is about to change!) as you have to create a Cloud Service project first, then add/replace the Web Role with a CGI Web Role.
For example you could create a Blank Cloud Service project:
In Solution Explorer, right click on the Roles node in the Cloud Service project Add | New Web Role Project…
Select CGI Web Role:
Which adds an ASP.NET Web Application project tailored to be the configuration and files conduit for a FastCGI Application to your Cloud Service:
What is the purpose of the CGI Web Role?
Even though Visual Studio doesn’t support languages like PHP, there are reasons for you to be interested in using Visual Studio when building a FastCGI application that runs on Windows Azure:
Not to mention that Visual Studio really has a first class source editor and a lot of other features you’ll be able to make use of.
(Please see the Windows Azure SDK documentation and the FastCGI sample for more information on hosting a FastCGI application on Windows Azure.)
[Update, voting for US entries has now concluded - opening for the international winner will open soon]
Go to http://www.newcloudapp.com/vote.html to browse the apps and vote for a winner of the Azure Services Platform Developer Challenge. Voting ends June 29th for the US winner. (voting will open July 10th (submission deadline of July 9) for the international winner).
Lots of cool apps there, definitely worth a look -- all running on Windows Azure.
Windows Azure Tools for Microsoft Visual Studio (includes SDK). If the release is still propagating, try the Direct Link
New for the May 2009 CTP:
Release notes/Known issues are available here
Visual Studio 2010 Beta 1 Support:
You can now use Visual Studio 2010 Beta 1 to build your Cloud Services. There are a couple of interesting things to note however:
Editing Role Properties
You can now use the Visual Studio Properties Window to edit some of the Role Properties like Enabling Full Trust and setting the instance count.
As always – we love getting your feedback, you can email me off this blog, visit our Forum or enter a bug.
[Update: With the November 2009 release of the Windows Azure Tools - this post is now obsolete - an updated post is available here]
Lately there has been a couple of threads on the forum and some internal email around setting up an https endpoint on a Windows Azure Cloud Service.
A good starting point is this article, but there are some common issues that people run into that I wanted to talk about.
First are the cert requirements.
When running on the Development Fabric, the certificate also needs to be self-signed – this is to prevent any security issues around leaking the private key of a real certificate.
Let’s walkthrough the steps to trying an https endpoint on the Development Fabric:
1) open the ServiceDefinition.csdef file in the CloudService project in Visual Studio and add a second InputEndpoint to the WebRole:
<InputEndpoint name="HttpIn" protocol="http" port="80" />
<InputEndpoint name="HttpsIn" protocol="https" port="443" />
2) If you have a self-signed certificate that meets the requirements above, you can skip ahead to step 9. Otherwise, let’s use the IIS manager to create a self-signed certificate
3) Open the IIS Manager and select “Server Certifiates”
4) On the right side under “Actions”, select “Create Self-Signed Certificate…”
5) Follow the steps in the IIS Manager and you’ll have a new self-signed cert that supports Server Authentication and has an exportable private key.
6) The newly created cert will be put in the Personal store in the Local Computer location. Windows Azure Tools (including cspack) look for the certs in the Personal store in the Current User location (we needed to settle on a location and didn’t want it to be one that requires admin elevation).
7) To move the certs to the Current User location, you can run mmc, add the Certificates snap-in for both “My User Account” and “Computer Account” and drag and drop the certificates to the Personal store in the Current User location. Alternatively, you can export and import.
8) If you ever export/import the cert, make sure you export the private key and on import mark the key as exportable:
9) Right click on the Cloud Service project in the VS Solution Explorer and click “Properties”. Click on the SSL tab and check to Enable SSL Connections under Development and click “Select from Store…”.
10) Select your certificate. Hit F5 to run.
11) Navigate to the https endpoint -- the browser will complain as expected because you are using a self-signed certificate:
12) To see the actual ports that were used for your service, you can bring up the Development Fabric UI (right click on the Development Fabric tray icon) and click on the Service Details for your Deployment:
13) When you are ready to publish to the real cloud, use the SSL Cloud Service settings to select a certificate for Publish – this is the certificate that is used when publishing for deployment.
Azure Services Platform Developer Challenge!
Everything you need to know from a page hosted on Windows Azure: http://www.newcloudapp.com/
Couple things to point out:
Pretty cool contest, can't wait to see the kinds of apps that get built -- Start your engines!
Back at Mix ‘09, we announced that Windows Azure will have support for specifying which geographical region you want your Cloud Service to run.
If you now go to create a new Hosted Service on the Azure Services Developer Portal, you will be presented with an option to put the service in an Affinity Group and select the region for that Affinity Group.
You will then see the Affinity Group listed on the summary page for your Hosted Service Project.
When you go to create another project, be it a Hosted Service or Storage Account, you can choose to put that storage account in an existing Affinity Group, this will geographically co-locate your compute and/or storage projects.
From the announcement referenced above:
Accounts inside an affinity group will be dealt with as one unit and placed together for connectivity. For example, if you create an affinity group placed in North Western United States and place multiple storage accounts and hosted services in there, we’ll allocate these together in that geographical region, so that all of the accounts will be close together from a network perspective
Pretty cool stuff, especially when data centers in more locations come online.
(Update 9/24/2009 -- We're now included in the Web Platform Installer! See: http://blogs.msdn.com/jnak/archive/2009/09/24/installing-the-windows-azure-tools-using-the-web-platform-installer.aspx)
One of the first things I do when I get a new box is install the Windows Azure Tools and SDK. (don’t you?)
Quite often, I forget to install and configure IIS7 – and receive the following message:
The Windows Azure SDK requires Internet Information Service 7.0 with ASP.Net Application Development components installed.
So how do I install IIS and the required components?
You could follow the instructions buried on the download page… or you can use the Microsoft Platform installer which is a heck of a lot easier. Let’s see how that would work.
1. Navigate to http://microsoft.com/web and click on “Get the Microsoft Web Platform”
At the time of this writing, there is a v1.0 and v2.0 beta you can try. We’ll show the 2.0 beta although you could use either.
2. Click on the download button.
3. Click on the Web Platform tab and customize the Web Server option with: ASP.Net, Default Document and CGI (if you want to run fastCGI apps) and any other features you want to add.
4. You can also click to add a database (SQL Express) if you need it and tools – including the free Visual Web Developer Express which our Windows Azure Tools support.
5. Click “Install” when you are ready. You’ll get an opportunity to review your selection, then the download and install will commence.
6. Install a few hot fixes manually:
7. Finally, if you are using WCF, you will want to install WCF HTTP Activation. (this is a .Net feature)
On Vista: From the Start menu, choose Settings | Control Panel | Programs | Programs and Features, Click Turn “windows Features On or Off”, under Microsoft .Net Framework 3.0, select WCF HTTP Activation
On Windows Server 2008 – In Server Manager under Features Summary, choose Add Features – under .Net Framework 3.0 Features, select WCF Activation.
8. Install the Windows Azure Tools
This is the way I setup my new machines nowadays, just so much easier and I get all of the other web frameworks (like MVC and Silverlight) at the same time.
What is the Service Package? It is what contains the Service Definition for your Cloud Service along with the content and binaries for each of the roles.
It comes in 2 flavors. The first being a folder structure with the extension csx. For example if you look in the output folder of the Cloud Service project (bin\debug or bin\release) you will see the following:
Where the highlighted CloudService6.csx file is the folder structure version of the Service Package – the Service Definition file is located there.
The Service Configuration file is kept separate to the Service Package as it can be updated independently of the Service Package, for example to update setting values or increase/decrease the number of instance of each of your roles.
The folder version of the Service Package is the output of the Cloud Service project. This is what is used to run the Cloud Service on the Development Fabric.
If you look in the WebRole and WorkerRole directories, you will see the content and binaries that will be used to run your roles.
The second flavor of the Service Package is the single file version (cspkg file extension), which is created when you publish the Cloud Service by right-clicking on the Cloud Service project and selecting “Publish…”
This is the file that you upload (along with the Service Configuration file) to the Windows Azure cloud to run your service.
The single file package is found in the Publish folder of the output directory of the Cloud Service project along with the Service Configuration file:
This is the directory that VS automatically opens up when you publish from the Cloud Service.
It is interesting to know about these two flavors of Service Packages so that you can know where to look to see what files are being packaged up and executed by the Development Fabric locally and/or Fabric in the cloud.
The single file Service Package is zipped and encrypted so you won’t be able to browse through it unless you set an environment variable to package without encryption.
Note: The steps to create an unencrypted package are for diagnostic purposes only and should not be used for production packages. Additionally, the method is only intended for internal use, is not supported and may be changed at any time. (enough of a disclaimer? :) )
With Visual Studio closed, create a new environment variable called: _CSPACK_FORCE_NOENCRYPT_ set the value to true. This will look like this:
You can access the environment variables dialog from the advanced tab on the System Properties from the Advanced system settings task button on the left of: Control Panel\System and Maintenance\System.
Now startup Visual Studio, load a Cloud Service project and hit publish. When you publish, you will see the following message in the output window:
C:\Program Files\MSBuild\Microsoft\Cloud Service\v1.0\Microsoft.CloudService.targets(0,0): warning : CloudServices44 : Forcing creation of unencrypted package.
Now, you can unzip your way through the single file Service Package. Rename the service package to .zip and unzip.
Inside the first directory you can unzip the WebRole_*.cssx and WorkerRole_*.cssx files to reveal your worker and web role directories.
One thing to mention here is that you can deploy both unencrypted and encrypted versions of the Service Package to Windows Azure, although I'll reiterate that you should really only deploy the encrypted version of your package.
Hope this helps with diagnostic and debugging type activities – we are thinking about how we can make this easier in the tools.
If you are trying a FastCGI application on Windows Azure and see the following message:
CCT: Error: FastCGI module at C:\Windows\system32\inetsrv\iisfcgi.dll with version 7.0.6001.22229 is not up-to-date.CCT: The system is missing a prerequisite to execute the service. Please see the release notes.
You are missing the following QFE: http://support.microsoft.com/kb/967131
We'll definitely improve the message -- just wanted to get some more help out there for any of you that run into this.
If you weren't able to make it to MIX09, you can catch videos of the sessions.
My session is available for watching here: Using the Windows Azure Tools for Microsoft Visual Studio to Build Cloud Services
If you haven't seen the keynotes, I highly recommend that you see them, lots of awesome announcements and they are pretty darn entertaining too.
You can also catch the other Azure related sessions.
Here's the list of Windows Azure sessions:
Lots of great information available, hope you enjoy.
Update: We've refreshed the release and this new release resolves these issues. See here for more information.
We recently helped out a couple of folks on the Windows Azure Forum and felt it would be useful to post some information about two issues we’ve been seeing in the March 2009 CTP.
Issue: Visual Studio closes unexpectedly when launching Help | About or creating a Cloud Service in some non ENU Operating Systems.
Workaround: Modify (you might have to add it if it's not there) the value of the following key to "False":
HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\9.0\Cloud Computing Tools\Update Notification\AutomaticUpdatesEnabled="False"
Issue: if you specify the SQL instance to use for the Development Storage (through the DSInit command line utility in the SDK), the “Create Test Storage Tables” command will fail.
Workaround: Please replace the Microsoft.CloudService.targets file with the file attached to this blog post.
This is useful for people that wish to use a different SQL Server instance other than SQL Server Express.
You can find the Microsoft.CloudService.Targets file to replace in your C:\Program Files (x86)\MSBuild\Microsoft\Cloud Service\v1.0 directory.
Hope this helps, stay tuned for more information.
One of the cool new features in the Windows Azure Mix 09 CTP is the ability to run your Web and/or Worker Roles in full trust (non-admin). This opens up all kinds of features that weren’t available in the previous CTPs.
An interesting feature, which is the subject of this post is the ability to make PInvoke calls.
One of the things I have noticed in playing with calling native code is that you have to be more aware of the actual environment in the cloud. For example, Windows Azure in the cloud:
I also want to reiterate here that your Role Instances run in separate VMs and those VMs can come and go – it’s important not to count on any file system persistence in the VM.
1. Create a new Web Cloud Service project. File | New | Project. Select Visual C#/VB | Cloud Services | Web Cloud Services
2. Add a project to your solution for your native code. Right click on the Solution Explorer and select Add | New Project…
3. Select “Win32 Project” and call it “NativeCalc”
Setup the win32 project to be a DLL – we’ll just call a simple C function from it. Select “Export symbols”.
3. Open NativeCalc.h and change the dummy fnNativeCalc function to:
NATIVECALC_API int AddNumbers(int left, int right);
Note that the extern “C” specifies to use C linkage convention – what you see for the exported symbol if you used dumpbin – instead of the C++ decorations. This is what PInvoke will look for.
4. Now implement the method in NativeCalc.cpp
NATIVECALC_API int AddNumbers(int left, int right)
return left + right;
5. Next we have to ensure that this DLL is included as part of the Service Package. See this post for more details.
First I set the output directory of the DLL to be in the Web Role project directory.
I build all then right click on the nativeCloudService_WebRole project in Solution Explorer and select Add | Existing Item | NativeCalc.dll
I then set the CopyToOutputDirectory property to “CopyIfnewer”
6. Add a button and a label on default.aspx and in the button handler, set the label to the output of the native call:
static extern int AddNumbers(int left, int right);
protected void Button1_Click(object sender, EventArgs e)
Label1.Text = AddNumbers(2, 3).ToString();
7. Set the enableNativeExecution attribute on the WebRole in the ServiceDefinition.csdef
<?xml version="1.0" encoding="utf-8"?>
<ServiceDefinition name="NativeCloudService" xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceDefinition">
<WebRole name="WebRole" enableNativeCodeExecution="true">
8. Run the application and hit the button – everything will work as expected – you just called native code running on Windows Azure!
9. If you want to publish and deploy this to the Cloud – make sure that the native DLL is being built in release mode and is built for x64. See the troubleshooting section below for more details.
Small troubleshooting section:
Description: The application attempted to perform an operation not allowed by the security policy. To grant this application the required permission please contact your system administrator or change the application's trust level in the configuration file. Exception Details: System.Security.SecurityException: System.Security.Permissions.SecurityPermission
When trying in the Cloud:
Compiling for x64 in Visual Studio related:
New release of the Windows Azure SDK and Tools!
From now on, you only have to download the Windows Azure Tools for Microsoft Visual Studio and the SDK will be installed as part of that package.
Windows Azure Tools for Microsoft Visual Studio (please give time for propagation or use the direct link to the download)
In a nutshell, you can now run managed code Full Trust and if you want to give fastCGI applications on Windows Azure a try, you can do that too!
Please install the following hotfixes:
What’s new in Windows Azure SDK
What’s new in Windows Azure Tools for Visual Studio
[For more recent information on using ASP.NET MVC with Windows Azure please see this post.]
ASP.Net MVC RC2 released a few days back and I've already gotten a number of requests to update the MVC on Windows Azure samples since they were getting a little stale.
I updated my posts on MVC and I also added more detail to the original "MVC on Windows Azure" post by making it a walkthrough -- hopefully it will be easy for you to duplicate the steps on your projects.
Also note that we've released a hotfix that will solve stability issues when using MVC with the Windows Azure Tools.