How to enable Azure VM IIS hosted website public access

  1. Setup IIS
  2. Confirm able to browse default website locally
  3. Azure Management Portal
  4. Select Virtual Machine
  5. Endpoints
  6. Add HTTP
  7. Confirm able to access the default site from a public web browser
  8. Optionally add FTP, HTTPS ( use for SSL )

Find and remove adware on Internet Explorer

Started getting adware underlined hyperlinks on IE today. This directs you to and then on to a web advert

With thanks to

Found in services and msconfig and disabled in both

  1. In RegEdit.exe delete following folder
  2. In Explorer
    %program files (x86)% delete folder Rr Savings
  3. In Explorer
    %program files% delete folder RrFilter
  4. Also in IE > Tools > Manage Add-ons
    Disable Adpeak – RrSavings
    Also More Information – Took a screen shot and noted the ClassID
  5. Searched for the ClassID in RegEdit and deleted it from a few 2-3 places


Azure Virtual Machines adding virtual hard disks VHD

See also Azure Powershell and Azure VM with SQL

If you have a Pluralsight subscription then they have a good course “Windows Azure Infrastructure as a Service Essentials” then chapter “Storage and Disks” and screen cast “Creating Virtual Hard Disks”

First create a local VHD

  1. Start – “Create and format hard disk partitions”
  2. Action Create VHD
  3. Set location, size, fixed size, OK
  4. Right-click on newly created disk and Initialise
  5. Think MBR – OK
  6. Detach VHD

Upload local VHD to Azure Storage using Azure Powershell

  1. Ensure that you can run local scripts, see Azure Powershell post
  2. Run script:
    add-azurevhd -destination http://<address&gt;<container>/<blobname>.vhd -LocalFilePath :\vhds\VHD01.vhd

Set as Virtual Machines Disk

  1.  Azure management portal
  2. Virtual machines
  3. Disks
  4. Create, enter name, pick from storage, OK

Attach to the Virtual Machine

  1. Azure management portal
  2. Virtual machines
  3. Select machine
  4. Dashboard
  5. Attach – Attach disk
  6. Read/Write
  7. Tick, OK






Azure Virtual Machines – with SQL Server

Setting up a VM for SQL Server Web Edition

  1. Created my first virtual machine with SQL Server Web edition on it.
  2. Added a windows user. Added the equivalent SQL Server windows user.
  3. Checked could login to SQL Server OK
  4. Used sysprep as a starting point
  5. Then took an image.
  6. Then created a new virtual machine from that image
  7. Logged in to new VM ok – but error on logging in to SQL Server.
  8. Then after a weekend the error had changed to “A connection was successfully established with the server, but then an error occurred during the login process (provider: Shared Memory Provider: 0 – No process is on the other end of the pipe)(Microsoft SQL Server, Error: 233)
  9. This was because SQL Server Agent was not running – started it
  10. In fact in SQL Server Configuration SQL Server Agent and Browser had to be changed to automatic startup
  11. Then back to original error

Error Login failed for user (Microsoft SQL Server Error 18456) on VM with SQL Server

  1. It seems that the user who created the SQL login on the first machine is not the same as the user who created the new machine after the sysprep
  2. So destroyed the machine and started again.
  3. New strategy – put SQL Server into Mixed Authentication Mode
  4. Create a SQL Server Login
  5. Give that login sysadmin
  6. Create the image.
  7. Create the VM from the image.
  8. Confirm that the Windows logins do not work for SQL Server
  9. Login as that SQL Server login admin created before, rather than the Windows Authentication only.
  10. Then script to drop and create the windows logins
  11. Issue resolved

Mixed Authentication Mode is required if logging into the SQL Server from another machine in any case.

So if creating a new VM from the image then start from step 7 above


Error: Login failed for remote SQL server



In the VM > Network and Sharing Center > View your active networks

The network had been set to private – reset to public and it now works again



How to setup a Virtual Machine for connection to SQL Server from another Machine


Azure Powershell

This was useful

When I installed Powershell I think I downloaded a publishsettings file. I copied this to c:\Temp and renamed it without spaces. Then as per above I used:

Import-AzurePublishSettingsFile ‘c:\temp\<publishsettingsfilename.publishsettings>’

Everything then worked including:




To store a script use notepad and change the file extension to .ps1


File ps1 cannot be loaded because running scripts is disabled on this system


To resolve this issue, follow these steps:

  1. Run the Windows Azure Active Directory Module for Windows PowerShell as an admin. To do this, click Start, click All Programs, click Windows Azure Active Directory, right-click Windows Azure Active Directory Module for Windows PowerShell, and then click Run as administrator.
  2. Set the execution policy to Unrestricted. To do this, type the following cmdlet, and then press Enter:
    Set-ExecutionPolicy Unrestricted
  3. Run the Windows PowerShell cmdlets that you want.
  4. Set the execution policy to Restricted. To do this, type the following cmdlet, and then press Enter:

    Set-ExecutionPolicy Restricted



  1. Open mmc.exe
  2. Add snap-in for Group Policy – local computer
  3. Computer configuration
  4. Administrative templates
  5. Windows components
  6. Windows Powershell
  7. Turn on Script Execution
  8. Right-click Edit
  9. Enabled
  10. Execution policy bottom LHS = Allow Local Scripts and remote Signed Scripts

After finish disable it.

Programming against Sharepoint (Online) Client Side Object Model CSOM


Add References to:

  1. C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.dll
  2. C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.Runtime.dll

Problem 1

The referenced assembly “Microsoft.SharePoint.Client, Version=, Culture=neutral, PublicKeyToken=71e9bce111e9429c, processorArchitecture=MSIL” could not be resolved because it has a dependency on “System.Web, Version=, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a” which is not in the currently targeted framework “.NETFramework,Version=v4.0,Profile=Client”. Please remove references to assemblies not in the targeted framework or consider retargeting your project. SharepointWinFormsCSharp

Solution 1

Ensure that the project targets .Net Framework 4 and not Client Profile

Project > Properties > Application > Target Framework

Problem 2

The type or namespace name ‘SharepointOnlineCredentials’ does not exist in the namespace ‘Microsoft.SharePoint.Client’ (are you missing an assembly reference?)

Solution 2A – use this

First check that the spelling is precise including casing

Second, odd, but I copied the references to the bin folder and re-directed the reference to there and it started working. Odd thing was when I then pointed the reference back it continued to work.

Solution 2B – just creates a new problem

  1. Select Reference Microsoft.Sharepoint.Client
  2. Right-Click > Properties
  3. Embed Interop Types change from False to True
  4. Build

This returns new problem

  1. Cannot embed interop types from assembly ‘c:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\15\ISAPI\Microsoft.Sharepoint.Client.dll” because it is missing either the ‘ImportedFromTypeLibAttribute’ attribute or the ‘PrimaryInteropAssemblyAsstribute’ attribute
  2. Cannot embed interop types from assembly ‘c:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\15\ISAPI\Microsoft.Sharepoint.Client.dll” because it is missing the ‘GuidAttribute’ attribute

How to use CSOM

After the above each of the use cases in the following demonstrations then worked.

How to: Complete basic operations using SharePoint 2013 client library code

            using (var context = new ClientContext(""))
                var web = context.Web;
                var login = "xx@xx";
                var password = "xxxx";
                var securePassword = new System.Security.SecureString();
                foreach (char c in password)
                context.Credentials = new SharePointOnlineCredentials(login, securePassword);

The end

SkyDrive Pro “Can’t connect to the specified SharePoint site…”


“Sorry we are having some temporary server issues.”
Office Outlook reporting that it is not activated

Solution 1

This may be a bit extreme and you may lose other settings, but this was the only thing I found that worked.
Internet Explorer > Tools > Internet Options > Advanced > Reset

Solution 2

My sub-site had unique permissions. When I removed the unique permissions, I was able to sync.

What did not help

Programs and Features > Office > Change > Repair

Windows Key – type credentials > Credential Manager > Remove a couple of the office credentials.

How to create a certificate – for Azure

Using MakeCert

After using makecert, it may say Succeeded, but you may not be able to find the certificate.
If you started from c:\Windows\system32 then It may be in c:\Windows\SysWOW64

To create your own self-signed management certificates which will be valid for Azure, open a Visual Studio command prompt as an administrator, and then run the following command:

makecert -sky exchange -r -n “CN=<CertificateName>” -pe -a sha1 -len 2048 -ss My “<CertificateName>.cer”

The CN may need to be

NOTE: If you get:
Error: CryptCertStrToNameW failed => 0x80092023 (-2146885597)

Then try manually deleting each ” and re-typing


Export from MMC

Not sure still learning, but current notes are

  1. Windows start type mmc.exe
  2. Probably current user for self-signed
  3. Select certificate
  4. Right-click All Tasks – Export
  5. Export with Private Key and Password
  6. Upload to the Service – Certificates in Azure



Configuring SSL for an application in Windows Azure

How to create a WCF Service Web Role and publish to Azure and consume it

Create the Project

Visual Studio > New Project > Visual Basic or Visual C# > Cloud > Windows Azure Cloud Service
> Select WCFServiceWebRole
If this is missing then Install “Windows Azure SDK for .Net”

Code quick start: Create and deploy a WCF service in Windows Azure

Code Quick Start: Create a client application that uses a WCF service deployed to Windows Azure

Also see:

Code the Project

Follow the instructions above.

You cannot overload a method. So I had GetMakes and GetMakes(VehicleTypeID) this will mean the service cannot be activated.

Deployment to Azure

Points to watch are:

  1. In ServiceConfiguration.Cloud.cscfg
    <Instances count=”2″ />
  2. In the role, e.g. WCFServiceWebRole1 on Configuration specify the storage account credentials for the Diagnostics results:
    Use the eclipse and pick existing Azure account

Change the name of a service

MyService.svc is actually 2 files, with a linked code behind file.
Using right-click MyService.svc may be opened for code or for markup. If opened for markup then the service name is exposed. If you change the name of the project then you need to change the name here to the fully qualified name.

Consume the service

Mostly fine by following the example. Notable point here.

  1. Add service reference to a project in Visual Studio
  2. Right-click and Configure Service Reference
  3. Under Data Type > Tick On the “Always generate message contracts”

Otherwise the Get..Request() or Get..Response() may not be visible.


You could remote desktop to the Azure instance and then use:

  1. the Event Viewer – Application to view errors.
  2. IIS > Management > Configuration Editor
    If this will not open, then it may display what error was found in the Web.Config file. Correct this.

For debugging In Web.confg you may add the following section so that actual errors appear on web inspection:

    <customErrors mode="Off"/>

but configSections must be first and there should be only one open and close tag for configuration.


Error 1

If debugging then it would crash OnStart when calling AzureLocalStorageTraceListener.GetLogDirectory. Issue here was in ServiceDefinition.csdef there was no log defined.

Error 1 Solution

       <LocalStorage name="WCFServiceWebRole1.svclog" sizeInMB="1000" cleanOnRoleRecycle="false" />

Error 2

Metadata contains a reference that cannot be resolved: ‘http://<ip address>:<port no>/CatalogueService.svc?wsdl’.
The document format is not recognized (the content type is ‘text/html; charset=UTF-8’).
Metadata contains a reference that cannot be resolved: ‘http://<ip address:<port no>/CatalogueService.svc’.
There was no endpoint listening at http://<ip address>:<port no>/CatalogueService.svc that could accept the message. This is often caused by an incorrect address or SOAP action. See InnerException, if present, for more details.
The remote server returned an error: (404) Not Found.
If the service is defined in the current solution, try building the solution and adding the service reference again.

Error 2 Solution

I had inadvertently commented out the [ServiceContract] from the IService
Also make sure that the markup of the service is correct.

Error 3

“The remote server returned an error (500) Internal Server Error”

Error 3 Solution

Unfortunately this just means there has been an error. I changed a number of things and then it started again, i do not know which fixed the issue for me:

  1. Added an [OperationContract] to the ICatalogueService and did not explicity implement it.
  2. An issue with remote desktop publish
  3. Overloaded a method with the same name
  4. Remmed out next line
    public interface ICatalogueService

Error 4

I had a test fail possibly when returning a lot of data.

System.ServiceModel.CommunicationException: The maximum message size quota for incoming messages (65536) has been exceeded. To increase the quota, use the MaxReceivedMessageSize property on the appropriate binding element. —> System.ServiceModel.QuotaExceededException: The maximum message size quota for incoming messages (65536) has been exceeded. To increase the quota, use the MaxReceivedMessageSize property on the appropriate binding element.

Error 4 Solution

Surprisingly I didn’t change anything on the outgoing service.
Instead on the calling application in the app.config file there are some settings for the bindings.

<?xml version="1.0" encoding="utf-8" ?>
                <binding name="BasicHttpBinding_IMyService" closeTimeout="00:01:00"
                    maxBufferSize="6553600" maxBufferPoolSize="524288" maxReceivedMessageSize="6553600"
            <endpoint address="http://xxx.xx/MyService.svc"
                binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IMyService"
                contract="CatalogueCloudService.IMyService" name="BasicHttpBinding_IMyService" />

Error 5 – The type or namespace ‘..’ could not be found (are you missing a using directive or an assembly reference?) in  – …\..\Reference.cs

Solution 5

I tried removing [Serializable][DataContract] from class and remove [DataMember] from properties and then re-deployed the web service and the error went away.

Error 6 – Web.Config errors

Resulted in Internal Server Erorr 500

Solution 6

See top of troubleshooting. Use IIS and try and use the Configuration Editor. This may display your error. Possible errors include:

  1. You should have only 1 configuration open and close tag
  2. configSections should be the first element


Error 7 Busy (Starting role… Unhandled Exception: Microsoft.WindowsAzure.ServiceRuntime.RoleEnvironmentException

Does not progress beyond this. You have to delete that deployment for now.

Solution to Error 7

This is similar to error 2 above.

The Web Role project in AzureLocalStorageTraceListener the name of the path must be the same as the service

publicclassAzureLocalStorageTraceListener : XmlWriterTraceListener

public AzureLocalStorageTraceListener() : base(Path.Combine(AzureLocalStorageTraceListener.GetLogDirectory().Path, “WCFServiceWebRole2.svclog”)) {}

publicstaticDirectoryConfiguration GetLogDirectory()
DirectoryConfiguration directory = newDirectoryConfiguration();
directory.Container = “wad-tracefiles”;
directory.DirectoryQuotaInMB = 10;
directory.Path = RoleEnvironment.GetLocalResource(“WCFServiceWebRole2.svclog”).RootPath;
return directory;

Error 8

The type ‘WCFServiceWebRole.VRMService’, provided as the Service attribute value in the ServiceHost directive, or provided in the configuration element system.serviceModel/serviceHostingEnvironment/serviceActivations could not be found.

Solution to Error 8

Right-Click on the service with the bug and use View Markup. The Service name may have got out of sync with the project name

<%@ServiceHostLanguage=”C#”Debug=”true”Service=”WCFServiceWebRole.MyService”CodeBehind=”MyService.svc.cs” %>


The name in the Azure Service Project > Roles > Your Role > Properties > Local Storage > must have the same name



Using SSL on the WCF WebRole

Links to:

If you have a subscription then see Pluralsight course: Windows Azure fundementals > Windows Azure Roles


Publish ASP.Net to Azure ‘freezes’

Steps to reproduce freeze when publishing a website to Azure

This assumes you have previously published a site

  1. Visual Studio
  2. Right-click on ASP.Net project that you wish to publish
  3. Publish
  4. Preview
  5. Start Preview
  6. Publish
  7. Freezes after build

How to resolve

If your solution has multiple projects, make sure that the ASP.Net project is the “Start up project”