Friday, March 16, 2012

Howto: configure WebDAV on Windows Azure WebRole instance

 

One day you may decide to configure WebDAV on your Windows Azure WebRole instance: for example, to perform file uploads without Azure deployments. BTW, be aware: all uploaded to WebRole instance files which do not exist in the deployment package are irreversible gone when the instance is migrated to another Azure host node or restarted.

But while the instance is running you may use the files uploaded via WebDAV.

Why we use WebDAV on Azure? Well, there was a business process to upload the Web content files to the former hosting platform prior to Windows Azure. The deployment chain includes a WebDAV upload and the tools are configured. Additionally,the uploaded files can be used immediately.With an usual Azure deployment package there is an instance outage for approximately 10-15 minutes. We need to update the files multiple times a day and use WebDAV to provide quick access to updated content files. Once uploaded via WebDAV the files can be accessed immediately. Additionally we update these files to deployment package and deploy then this package overnight while the outage of instance is not so critical.

Here are steps to activate and configure WebDAV on Windows Azure WebRole.

Configure Windows Server 2008 R2 as instance OS

First, be sure you use Windows Server 2008 R2 as instance OS. Windows Server 2008 has no WebDAV setup package out-of-box and requires download and setup of WebDAV modules. Windows Server 2008 R2 has WebDAV setup as feature package and requires only activation and configuration.

To ensure and configure right version of OS launch Windows Azure management portal and open popup menu on the selected deployment:

image

In popup menu select “Configure OS”:

image

You may see Windows Server 2008 SP2 as current OS version:

image

Select “Windows Server 2008 R2” and confirm with “OK”:

image

The system needs some time to be reconfigured:
image

All instances will be updated:

image

After all the instances are reconfigured you may use RDP to open terminal session to each instance to ensure configured OS version. The manual for RDP configuration on Azure is here: http://msdn.microsoft.com/en-us/library/windowsazure/gg443832.aspx

You will need RDP to each instance for WebDAV configuration. Use “Connect” button in management portal:

image

You should see the server configuration window with the current OS version information:

image

Alternatively you can start “winver”:
image

…and see the OS version:
image

Activate WebDAV

WebDAV is a feature of IIS and can be activated via Server Manager:

image

Select “WebDAV” in Role Services:

image

Confirm installation:

image

The installation process begins:

image

Configure WebDAV

Configure WebDAV for Website using IIS Manager:

image

Select “WebDAV Authorization rules” in IIS features of the Website:image

Enable WebDAV for the Website:

image

Once WebDAV is enabled, the option to disable WebDAV appears:

image

Add authorization rule to provide access to the file system, select content type, user(s) and permissions:

image

Review configured rules:

image

Do not forget to enable Windows Authentication on Website – otherwise the WebDAV users cannot login. Use “Authentication” IIS feature of the  Website:

image

Enabled Windows Authentication looks like:

image

Complete!

Access WebRole instance using WebDAV

From now you can access file system on WebRole instance using WebDAV. On the client open Windows Explorer:

image

Select “Map network drive”:

image

Select “Connect to a Web site…”:

image

Add network location:

image

Specify URL to the WebRole where WebDAV is enabled and configured:

image

Enter user login and password when prompted (use credentials you configured in WebDAV authorization rules):

image

Windows Explorer opens the location you configured:

image

You can use ordinary file system functions to upload to or download from WebRole instance.

Enjoy!

Tuesday, March 06, 2012

WMI error: Retrieving the COM class factory for component with CLSID {BDEADF26-C265-11D0-BCED-00A0C90AB50F} failed due to the following error: 800703fa

 

We used WMI from ASP.NET code to get CPU(s) ID for the current host. It worked a while, but suddenly stopped – with message:

Retrieving the COM class factory for component with CLSID {BDEADF26-C265-11D0-BCED-00A0C90AB50F} failed due to the following error: 800703fa

Reload user profile for AppPool identity – as described here – didn’t help.

Once downloaded and run WMIDiag the system came back to running state.

Friday, February 24, 2012

Another way to check database version before automatic deployment

With VS2008 (GDR) / 2010 / 2011 you may use automatic deploy scripts built with VS and based on vsdbcmd.

If you track the database version inside of your database (for example, in a separate table), you may need to check the current database version before incremental update – in some cases you may support the update only for dedicated versions and above and not for older versions.

You can force deployment break in the pre-deployment script after check for database version – if the database version is not supported for update:

--- get database version from current database

select @CurrentVersion =[PARAM_VALUE] from [MySystemParameters]
   where
   [PARAM_NAME] = 'DBVERSION'

--- check the version and break the deployment if the version is not supported

--- the sample is simplified: in real life you will check major version, minor version, build number etc.

if not ( @CurrentVersion >= @MinSupportedVersion)
   begin
      raiserror ('Current database verison is not supported and cannot be updated',18,0)
      set noexec on
   end

When you start the script on the target box, the deployment break looks like following:

x10sctmp

Enjoy!

Thursday, January 26, 2012

Problem with DATEV on changing computer name

Very simply: NEVER CHANGE THE MACHINE NAME once you installed DATEV.

You can join and leave domains and workgroups, but cannot change the machine name.

Once you’ve changed the machine name, you aren’t able to view old bookings and to enter new.

The only way is to revert machine to former name. Enjoy!

Friday, January 06, 2012

XMLWriter ignores XMLWriterSettings: generated XML is “UTF-16” instead of “UTF-8”

Once you need to generate a XML document in your ASP.NET application (for example, to offer it for download), you will sooner or later decide to use the XMLWriter class of .NET Fx.
So you’ll write a piece of code like: 
  
string fileName = buildDownloadFilename();
XDocument xmlDocument = generateXML();
if (xmlDocument != null)
   {
     StringBuilder sb = new StringBuilder();
     XmlWriter xmlWriter = XmlWriter.Create(sb);
     xmlDocument.Save(xmlWriter);
     xmlWriter.Close();
     string strContent = sb.ToString();
     Response.ContentType = "text/xml";
     Response.AppendHeader("content-disposition", String.Format("attachment;filename={0}", fileName));
     Response.AppendHeader("Content-Length", strContent.Length.ToString());
     Response.Write(strContent);
And you’ll be definitely surprised seeing the output XML declaration with encoding “UTF-16”.

Well, extending the code snippet with explicit XMLWriterSettings, you’ll land on:

string fileName = buildDownloadFilename();
XDocument xmlDocument = generateXML();
if (xmlDocument != null)
   {
     StringBuilder sb = new StringBuilder();
     XmlWriterSettings settings = new XmlWriterSettings();
     settings.Encoding = Encoding.UTF8;
     XmlWriter xmlWriter = XmlWriter.Create(sb, settings);
     xmlDocument.Save(xmlWriter);
     xmlWriter.Close();
     string strContent = sb.ToString();
     Response.ContentType = "text/xml";
     Response.AppendHeader("content-disposition", String.Format("attachment;filename={0}", fileName));
     Response.AppendHeader("Content-Length", strContent.Length.ToString());
     Response.Write(strContent);
And you’ll be still surprised seeing the output XML declaration unchanged with encoding “UTF-16”.

The reason is, the settings of XMLWriter target (in this sample – StringBuilder) override the XMLWriterSettings parameters already in XMLWriter constructor.

The way out is, use an alternate target for XMLWriter, supporting the encoding you need. For example:

string fileName = buildDownloadFilename();
XDocument xmlDocument = generateXML();
if (xmlDocument != null)
   {
    XmlWriterSettings settings = new XmlWriterSettings();
    settings.Encoding = Encoding.UTF8;
    MemoryStream ms = new MemoryStream();
    XmlWriter xmlWriter = XmlWriter.Create(ms, settings);
    xmlDocument.Save(xmlWriter);
    xmlWriter.Close();
    string strContent = Encoding.UTF8.GetString(ms.GetBuffer());
    Response.ContentType = "text/xml";
    Response.AppendHeader("content-disposition", String.Format("attachment;filename={0}", fileName));
    Response.AppendHeader("Content-Length", strContent.Length.ToString());
    Response.Write(strContent);
Also check the solution here: http://blogs.msdn.com/b/kaevans/archive/2008/08/11/xmlwritersettings-encoding-being-ignored.aspx

Enjoy!

Tuesday, December 13, 2011

Configure automatic date and time synchronization on Windows Server 2008 R2

If you like to see your Windows Server 2008 R2 automatically syncing it’s date and time settings, do following:

  • Start console as administrator
  • Stop the service

    net stop w32time

    image
  • Run

    w32tm /config /syncfromflags:MANUAL /manualpeerlist:<list of NTP servers>

    image
    For list of public NTP servers please refer to: http://support.ntp.org/bin/view/Servers/NTPPoolServers
    We use 0.europe.pool.ntp.org to 3.europe.pool.ntp.org
  • Start the service again

    net start w32time

    image
  • Check the system event log for successful configuration:

    The time provider NtpClient is currently receiving valid time data from 0.europe.pool.ntp.org,1.europe.pool.ntp.org (ntp.m|0x1|0.0.0.0:123->85.236.42.140:123).

    image

From now your server will sync the date and time settings automatically.

You can update the configuration of the local time service also without service restart: just run

w32tm /config /update /syncfromflags:MANUAL /manualpeerlist:<list of NTP servers>

If you plan to let other boxes in your network segment sync their date and time settings with the setting of this box, you have to configure the time service on this box as reliable:

w32tm /config /reliable:yes

For more options refer to Microsoft article:
http://technet.microsoft.com/en-us/library/cc773263%28WS.10%29.aspx

Enjoy!

UPD: here the script sample to copy/paste. ATTENTION “w32tm /config…” is one line – remove evtl. line breaks after copy

rem stop w32time
net stop w32time
rem config service
w32tm /config /syncfromflags:MANUAL /manualpeerlist:0.europe.pool.ntp.org,1.europe.pool.ntp.org,2.europe.pool.ntp.org,3.europe.pool.ntp.org
rem restart w32time
net start w32time

Saturday, November 26, 2011

Resize Windows 7 partition on HDD

!!! NOT AN ADVERTISMENT, JUST SUGGESTION !!!

The problem: the partition on the HDD for Windows 7 was measured too small – after a year the system partition was nearby completely exhausted.

Standard tools won’t help. The home users can use a free tool as I did:  EASEUS Partition Master.

Enjoy!

Monday, November 14, 2011

RDP to Windows Server 2008 R2 failed with message: "The connection cannot continue because the identity of the remote computer cannot be verified"

Using RDP to each serve in our development farm, we encountered suddenly following error:

x10sctmp
Error Message: "The connection cannot continue because the identity of the remote computer cannot be verified"

We can still get RDP to the machine using it’s IP address, but not using the machine name – even not fully qualified with domain name etc.

The reason is the difference in time settings:

time settings at the target machine:

x10sctmp0

time settings at the machine with RDP client:

x10sctmp1

20 minutes difference caused the difference. After the time was synchronized, we were able to connect the target machine again.

Also a centralized time synchronization across the farm may be used to avoid the problem.

UPD: the problem seems to be known and mentioned at

http://developers.de/blogs/edin_mulic/archive/2009/08/18/cannot-establish-remote-desktop-connection.aspx

Tuesday, October 11, 2011

Missing tray icon for Windows Live Messenger on Windows Server 2008 (R2) and Windows 7

You may miss the tray icon for Windows Live Messenger on machines running Windows Server 2008, Windows Server 2008 R2 or Windows 7. The process is running, you get – depending on configuration – bubble notifications, but see no tray icon to open messenger window.

Refer to article

http://www.sevenforums.com/tutorials/3794-windows-live-messenger-taskbar-notification-icon.html,

set the compatibility for msnmsgr.exe to Vista (on Windows Server 2008 R2 or Windows 7) or Windows XP (for Windows Server 2008), restart Messenger (just kill the process and restart) and enjoy!

Problem: cannot open PDF attachments using Outlook 2007 / 2010

Using Outlook 2007 or 2010 you may encounter strange problem:  PDF mail attachment won’t be opened with Acrobat Reader X (we monitored the problem with Outlook 2007 and 2010 using Acrobat Reader X 10.1.1).

While the attachment can be previewed in Outlook mail reader pane:
image

a double click on the same attachment in the same mail brings the Acrobat Reader X Window with error dialog box above saying: “There was an error opening this document. Access denied.”

x10sctmp2

The side effect is: if at least one Acrobat Reader X instance (program window on desktop) is already running, the attachment will be opened properly. Only if there’s no Acrobat Reader X window opened before you try to open a PDF mail attachment from Outlook – the error message appears.

The solution is:

  • open Acrobat Reader X
  • navigate menu Edit->Preferences:
    image
  • uncheck “Enable protected mode at startup”:
    image
  • confirm appearing dialog with “Yes”:
    x10sctmp4
  • close Preferences Dialog with “OK”
  • close Acrobat Reader X
  • retry to open PDF mail attachment
  • …enjoy!

Saturday, October 08, 2011

Microsoft Windows Azure is the best in the cloud speed test

x10sctmp3

Details here:
https://www.cloudsleuth.net/web/guest/global-provider-view

The test Azure account can be obtained here:
https://windows.azure.com/default.aspx

(Windows Live account required).

Build your Azure service and enjoy!

Tuesday, October 04, 2011

Relax 1

This summary is not available. Please click here to view the post.

Thursday, September 15, 2011

Visual Studio reports error: "Installation of this application requires a Windows Store Developer license …"

You downloaded Windows 8 CTP with developer tools, you start pre-installed Visual Studio 11 Express for Windows Developer Preview, you try to create a new application project – and get the error message:

"Installation of this application requires a Windows Store Developer license…"

The reason is: you need to install a developer license locally to your machine to get the development environment working properly.

  • exit Visual Studio
  • make sure your Windows 8 instance is connected to the internet
  • restart Visual Studio and confirm dialog box informing about installation of developer license

The error message must be gone: enjoy it – otherwise the license was not installed properly.

Wednesday, September 14, 2011

Download Windows 8 Preview

Windows 8 Preview can be downloaded here: http://msdn.microsoft.com/en-us/windows/apps/br229516

Facts:

  • available are x86 and x64 ISO (english)
  • additionally x64 with developer tools:
    image
  • OS can be installed virtualized (using Hyper-V)

Download, install and enjoy!

x10sctmp1x10sctmp0

Thursday, September 08, 2011

Hyper-V on Windows 8

Yes, it is true: Hyper-V comes with Windows 8 (x64 version):

http://blogs.msdn.com/b/b8/archive/2011/09/07/bringing-hyper-v-to-windows-8.aspx

Starting with Windows 8 we forget the difficulties to set up a proper virtual development environment, as described here.

Simply setup Windows 8 and enjoy!

Friday, July 29, 2011

Low-budget warm-up for Web application or how to automate ping a Website

In different IT scenarios there’s a need to access a Website just to check if it is available or even to ignite it’s start.

There are some automation tools for this purpose: I’ve seen even a download from Microsoft Website for warm-up of Microsoft CRM Websites – but do not recall where.

The quick and cheap alternative is to use PowerShell script for this purpose and bind it to a scheduled task.

This is the script – quite self-explanatory

    #check and create an eventlog source to report results of website probing
$eventLogSource =
"ProbeWeb";
if (![system.diagnostics.eventlog]::SourceExists($eventLogSource))
{
new-eventlog -logname Application -source $eventLogSource
}
#create webclient
$webClient = new-object System.Net.WebClient
$output = "";
$webSite = “http://winmike.blogspot.com”;
$startTime = get-date
#probe thewebsite
$output = $webClient.DownloadString($webSite)
$endTime = get-date
#test website response for desired character sequence
if ($output -like "*Mike*")
{
$message = $webSite + " succeeded " + $startTime.DateTime + " " + ($endTime -$startTime).TotalSeconds +
" seconds"
}
else
{
$message = $webSite + " failed " + $startTime.DateTime + " " + ($endTime - $startTime).TotalSeconds +
" seconds"
}
#record the results
write-eventlog -logname Application -source $eventLogSource -eventID 42
-message $message
Save this script in a file on the disk (for exampe, in c:\scripts\probeweb.ps1).
Start the script from powershell
x10sctmp0
and you will see the output in the eventlog - smth like that:
x10sctmp
Well, now bind it to a scheduled task. Open the Task Scheduler Library (via computer management) and select “Create Basic Task…”:
x10sctmp1
Enter task name and description, then select time period to repeat the task:
x10sctmp2 x10sctmp3
Select “start a program! as a task action:
x10sctmp4
Enter program name as follows
c:\windows\system32\WindowsPowerShell\v1.0\powershell.exe
(check the %SystemRoot% – your drive letter and path may vary)
and
c:\scripts\probewe.ps1
as argument (or alternate path to your script):
x10sctmp5
Review summary of the task:
x10sctmp6
…and confirm the task. You will see the task in the list of your task library:
x10sctmp7
Open the task properties and assure “Run whether user is logged on or not” is selected and the correct user account is used as execution context.
x10sctmp9
Confirm the password if requested.
Run newly created task to make sure it works:
x10sctmp10
Analyze the results
x10sctmp11
…and enjoy!

Monday, July 11, 2011

CD/DVD/Data Recovery source (hints and utilities)

Neither an advertisement, nor announcement. No my personal warranty. Only recommendation.

I was looking for help to rescue some data on my older CDs and HDDs. Found here: RLAB.

x10sctmp

You’ll find there many useful data recovery utilities – and numerous freeware among them.

Used with success:

R.Viewer – creates list of the disk files in different formats. This utility is very useful to get a snapshot of the file list on your drive: for example, to compare it with an earlier backup set or for other purposes. Supports CSV, HTML, XML formats – the result can be used in Microsoft Excel for filtering,sorting and further processing.

CHKParser32 – supports recovery of the damaged data, found after running chkdsk utility. Check Disk (chkdsk) utility collects “orphaned” or other way damaged files in .chk files. CHKParser32 helps to join them into meaningful data files (pictures, texts etc.).