Thursday, March 28, 2013

Cannot create/reset deployment credentials on an Azure Web Site?

Issue

I encountered a problem recently, attempting to browse Azure Web Site using FTP access. What I was actually trying to do is getting my custom logs written down to App_Data. In order to get FTP access, I started to create an account for this, according to my own understanding and many instructions in the Internet.



Having typed a (valid) user name and (valid) password, I pressed the tick to confirm creation/reset. It led me to error message like this (Failed to Set Credentials with error: "Please, try again. If the problem persists, contact support."):


Furthermore, my just typed credentials did not appear in the Quick Glance:

As you can see, I used free mode, so I could not figure on Microsoft support, since they give only Billing support for free plans:



You know, I even started of grief to think about writing a temporary custom viewer of App_Data.

Cause

To be honest, I did not find out the actual reason why my deployment/FTP user was Not Set. I don`t even know whether this was a temporary problem or a permanent bug. But...

Solution (workaround)

In spite of the fact that you cannot create an account for FTP access, there is one. Moreover, you can easily find it under the nearest link, namely "Download publish profile":


This link will download the well-known file of *.PublishSettings, it can be opened with well-known notepad. Actually, it contains two sections, one of which (//...@publishMethod=FTP) includes the information we are looking for (search for the words selected as bold and red below at once in the notepad):

<publishData>
  <publishProfile 
      profileName="{pubName} - Web Deploy"
      publishMethod="MSDeploy"
      publishUrl="{pubUrl}.publish.azurewebsites.windows.net:443"
      msdeploySite="{pubName}"
      userName="${pubName}"
      userPWD="{generatedPassword 1}"
      destinationAppUrl="http://{pubName}.azurewebsites.net"
      SQLServerDBConnectionString=""
      mySQLDBConnectionString=""
      hostingProviderForumLink=""
      controlPanelLink="http://windows.azure.com">
    <databases/>
  </publishProfile>
  <publishProfile
      profileName="{pubName} - FTP"
      publishMethod="FTP"
      publishUrl="ftp://waws-prod-bay-001.ftp.azurewebsites.windows.net/site/wwwroot"
      ftpPassiveMode="True"
      userName="{pubName}\${pubName}"
      userPWD="{generatedPassword 2}"
      destinationAppUrl="http://{pubName}.azurewebsites.net"
      SQLServerDBConnectionString=""
      mySQLDBConnectionString=""
      hostingProviderForumLink=""
      controlPanelLink="http://windows.azure.com">
    <databases/>
  </publishProfile>
</publishData>

Surprisingly, these credentials did the work properly. Of course, if not to forget to turn on Passive Mode for FTP. Now we've got  the FTP access and reviewed the content of App_Data folder even in free plan.

UPDATE. It looks like some information about this has already appeared in the Internet.

Wednesday, March 20, 2013

CSRun: why doesn't it work?

Undoubtedly, there may be many causes of the question set in the subject. But the first thing you should look at is whether you are trying to control (start, shutdown, etc) the emulation and control your emulated services (run service, update deployment, etc) at the same time. Moreover, it won't start devfabric and devstore simultaneously. In other words, CSRun confuses if you give it too many tasks at once. To resolve this kind of issue, just split it in two, three or more calls of CSRun, even though you might expect that single call will work for you. To be absolutely precise and to make it visual, I prepared the batch code samples below.

@REM Incorrect, do not do this way!!!
csrun.exe ^
  /run:MY.packed\MYS.csx;.\MYS\SConfig.Local.cscfg ^
  /launchbrowser /devfabric:start /devstore:start

Exactly, CSRun will attempt to do the first thing it finds in the parameter list. In the example above, it will try to run the MYS.csx package on the emulator using SCongig.Local.cscfg configuration file. It won't try to start the emulation before running the package. It won't even work as expected if you change the order in this way:


@REM Incorrect, do not do this way!!!
csrun.exe /devfabric:start /devstore:start ^
  /run:MY.packed\MYS.csx;.\MYS\SConfig.Local.cscfg ^
  /launchbrowser

In this example, it will start emulator and start compute emulation only, being reluctant to start storage emulation and to deploy the service package for running. To achieve the correct result, you merely call every implied action one by one, in separate lines:

@REM Correct, do this way!!!
csrun.exe /devfabric:start
csrun.exe /devstore:start 
csrun.exe ^
  /run:MY.packed\MYS.csx;.\MYS\SConfig.Local.cscfg ^
  /launchbrowser
 
This approach will do what you expected. The only further issue I can imagine is that you will have to insert a pause between calls, since storage emulator, for example, requires some time to start properly.  Nevertheless, in my practice it worked correctly and did the work.

P.S. For Russian speakers. Just call it "ЦСрань", and you won't be mistaken.