Friday, January 6, 2012

Windows Azure - Access to the path 'ServiceDefinition.build.csdef' is denied.

If you receive this error:
Error 102 Unable to copy file "ServiceDefinition.csdef" to "ServiceDefinition.build.csdef". Access to the path 'ServiceDefinition.build.csdef' is denied. C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v10.0\Windows Azure Tools\1.4\Microsoft.WindowsAzure.targets

The problem is that the file 'ServiceDefinition.build.csdef' is read-only. You will be able to find this file in your cloud project (.ccproj) directory. If you remove the read-only setting, the error will disappear and build and publish commands will work properly.

Could not establish trust relationship for the SSL/TLS secure channel

This is a common problem in the testing world where you deploy a service on a HTTPS endpoint by using a self-signed certificate.
When you try to send a request to this service using HTTPWebRequest/WebClient, you see the error:
The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel.
The solution to this problem is to ignore the trust by using the following code:

using System.Net;
using System.Net.Security;

           
ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(delegate { return true; });

HttpWebRequest request = (HttpWebRequest)WebRequest.Create("https://www.mysite.com");

HttpWebResponse response = (HttpWebResponse)request.GetResponse();

Stream stream = response.GetResponseStream();

StreamReader sr = new StreamReader(stream);

string resp = sr.ReadToEnd();