Emulator doesn't work after SDK update to 1.6

Nov 28, 2011 at 4:04 PM

Hi volks,

I use windowsazure4e. Today I updated everything on my machine to Windows Azure SDK 1.6 (http://www.microsoft.com/windowsazure/sdk/).

But now when I try to get my project runnig as usual (out of eclipse), nothing happens. Even if I start the emulator manually (csrun.exe /devfabric:start).

I also did the SDK for PHP update to 4.0.5 with non positive results.

Do you have some hints for me?

Thanks and best regards...

Editor
Nov 28, 2011 at 5:48 PM

Hello,

The best hint I can give you is to stop using windowsazure4e. That is an old project that has not been updated for a long time. Download the Windows Azure SDK for PHP and set it up, then develop your PHP project however you would like and use the command line tools provided by the PHP SDK to build and package your application.

http://azurephp.interoperabilitybridges.com/articles/setup-the-windows-azure-sdk-for-php

http://azurephp.interoperabilitybridges.com/articles/build-and-deploy-a-windows-azure-php-application

Cheers,
Ben

Nov 28, 2011 at 10:29 PM

@aurelious - I did file a bug on windowsazure4e - http://sourceforge.net/tracker/index.php?func=detail&aid=3443775&group_id=266877&atid=1135912 and I describe a workaround that got me going there, altough it is a very ugly workaround.

@blobaugh - I understand this might not be updated further.... but it is a shame. I had tried for a few hours to get going with the command line tools provided here at first, and got fairly frustrated with them. Then I tried the eclipse + plugin method and, even with that bug and workaround, I got up and running MUCH faster. It's not that I am a command-line novice, and when doing PHP on Linux i typically don't even use an IDE and do everything in a terminal window with VI....  but the batches and procedures and descriptions on http://azurephp.interoperabilitybridges.com/ just are A LOT of documents to go thru, with links back and forth between the various procedures; some of the procedures are not up-to-date with the current scripts code either and there are a few bugs and things to overcome that just don't currently make it as easy as we would all like. I just found them hard to follow and they got me not even halfway there.

Editor
Nov 28, 2011 at 10:39 PM

@dani313 Please let me know how I can help you. And if there are any bugs I will get the documentation updated for you. As far as I know the docs all work

Nov 29, 2011 at 3:00 AM

Thank you Ben for following up on this separately too!

My main issue was DefaultScaffolder.phar file which was missing from the ZIP file I had initially downloaded, for some reason. Grabbing the file from the source tree as you suggested got me unstuck and I am now able to build and deploy PHP apps both to the DevFabric as well as to the real cloud.

Nov 29, 2011 at 9:52 AM

@dani313 Thanks a lot for your response. It's good to see, that I'm not alone with this problem. It's truly a shame that there is no further development for the PHP community since more than one year. If I had knew this before, I would not have took the decicion to develop PHP within the Azure Cloud. Fortunately I'm still able to switch my application to a classical Apache Server. But I don't really want to go this way.

I worked this around for the time being by creating a single folder, and dumping all the files together. Probably some symbolic links would work too… but I believe it would be best to have the plugin updated.

Do you have a more detailed HOWTO for your fix?

Editor
Nov 29, 2011 at 2:38 PM

@everyone The archive has been updated to include the missing scaffolds

@aurelious It is still quite simple to develop PHP applications for use on Windows Azure. Read the following tutorials

http://azurephp.interoperabilitybridges.com/articles/setup-the-windows-azure-sdk-for-php

http://azurephp.interoperabilitybridges.com/articles/build-and-deploy-a-windows-azure-php-application

@dani313 Though this is no longer under active development it is an open source project. Feel free to contribute to it http://sourceforge.net/projects/eclipse-azure/

Nov 29, 2011 at 5:04 PM

@aurelious - essentially, the new azure SDK has files split into multiple folders, and eclipse expects to find them all in the same folder. I simply copied the content of "C:\Program Files\Windows Azure SDK\v1.6\bin" and "C:\Program Files\Windows Azure Emulator\emulator" into a new common folder (i.e. "c:\AzureHack") and told Eclipse to search in there. Of course this solution is UGLY, because every time you update the SDK you will have to manually keep those files uptodate in multiple places... I do NOT recommend you do this.

In the end, Ben helped me yesterday (there was a missing file which has now been included in the download package) and the scrips and tutorials here work just fine (when all the files are there! :-)). You can use any editor or IDE of choice to write your code - it is just the deployment which is done with a command line vs. a GUI.

Nov 29, 2011 at 5:25 PM

@dani313: I think I understand your path changes. I'm at the same point now.

@blobaugh: I red the tutorial the whole day up and down, and faced the same problems like dani313.

cspack always throws an exception about an invalid path format. I'm not able to see the problem in my app call, maybe you can face it out:

"c:\azuresdk\cspack.exe" C:\Stats\ServiceDefinition.csdef /role:WebRole; /out:C:\Stats\build\Stats.cspkg

(I put all relevant files from the SDK and emulator into the folder c:\azuresdk to solve space problems with the path names).

Nov 29, 2011 at 7:08 PM

@aurelious - please use the commands described in http://azurephp.interoperabilitybridges.com/articles/build-and-deploy-a-windows-azure-php-application#h4Section0 - those would be

  • package create -in="C:\temp\WindowsAzurePHPApp" -out="C:\temp\WindowsAzurePHPApp\build" -dev=true  --> for the Development Environment, and
  • package create-in="C:\temp\WindowsAzurePHPApp"-out="C:\temp\WindowsAzurePHPApp\build" -dev=false --> for the "real" Azure

"package" is a batch that acts as a wrapper for CSPACK and will call that for you with the right options.

You also do NOT need my hack descibed above if you are using the scripts and instructions associated with http://azurephp.interoperabilitybridges.com and with this codeplex project. That is just a hack for the eclipse plugin - which is a DIFFERENT way of doing this.

For the scripts described in these procedures, you will simply have added the right locations to the PATH variable as described on http://azurephp.interoperabilitybridges.com/articles/setup-the-windows-azure-sdk-for-php

 

 

Nov 30, 2011 at 12:40 PM

The problem is that I want to use the old folder structure given by eclipse:

C:\WindowsAzurePHPApp
 |_ ServiceDefinition.csdef
 |_ ServiceConfiguraion.cscfg
 |_ ServiceDefinition.csx (Development approot folder)
 |_ WindowsAzurePHPApp.cspkg (Package file)

C:\WindowsAzurePHPApp_WebRole
 |_ php
 |_ Web.config
 |_ index.php

With this structure the package script doesn't work.

But when I excute the cs... commands manualy it seams to work:

C:\WindowsAzurePHPApp>cspack ServiceDefinition.csdef /role:WebRole;..\WindowsAzurePHPApp_WebRole; /out:build /copyOnly

C:\WindowsAzurePHPApp>csrun /run:build;ServiceConfiguration.cscfg /launchBrowser

The browser opens but now I get an IIS error :(


There are some other points I figured out which are different since SDK 1.6:

  • With the new scafolder stuff the PHP now is integrated by startup task and not like before by FastCGI Module Handler inside the web.config.
  • When I try to build the package, cspack tells me that Web.roleconfig is unsuppored

Is there somewhere an explanation for these changes?

It's still hard to get all these information and to get system running like before. At the moment I'm in a dead end.

Nov 30, 2011 at 2:36 PM

When I try to start the Sample WebRole from http://azurephp.interoperabilitybridges.com/articles/build-and-deploy-a-windows-azure-php-application

scaffolder run -out="C:\temp\WindowsAzurePHPApp"

package create -in="C:\temp\WindowsAzurePHPApp" -out="C:\temp\WindowsAzurePHPApp\build" -dev=true

I get the following errors in startup-tasks-error-log.txt:

Ausnahme beim Aufrufen von "SetEnvironmentVariable" mit 3 Argument(en):  "Der a
ngeforderte Registrierungszugriff ist unzul„ssig."
Bei C:\temp\WindowsAzurePHPApp\PhpOnAzure.Web\bin\add-environment-variables.ps1
:6 Zeichen:38
+ [Environment]::SetEnvironmentVariable <<<< ("RoleName", [Microsoft.WindowsAzu
re.ServiceRuntime.RoleEnvironment]::CurrentRoleInstance.Role.Name, "Machine")
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : DotNetMethodException

Editor
Nov 30, 2011 at 3:04 PM

aurelious,

The reason for the changes is quite simple, the old tools were extremely limited and only allowed very simple web applications and no flexibility to take advantage of platform features such as Remote Desktop, choosing the OS, instance sizes, etc. The new tooling is much more powerful and opens your projects to the full potential provided to PHP on Windows Azure. Additionally, the old tools did not run a full version of PHP, the new tools integrate PHP into the IIS processes seamlessly.

The caveat is that if you are still using the old tooling (Note: the new tooling has been out for many months) you will need to alter your application slightly. I highly recommend reading the following tutorials:

http://azurephp.interoperabilitybridges.com/articles/setup-the-windows-azure-sdk-for-php
http://azurephp.interoperabilitybridges.com/articles/build-and-deploy-a-windows-azure-php-application

Something specifically that you may need to do is reinstall the Windows Azure 1.6 SDK to restore the paths to their correct location. The "hack" mentioned previously will break support of the SDK. Restore it and your problems may go away.

The other thing you need to do is copy your application files out of the old structure (Do not copy the php folder or Web.config) and into the new structure:

Contents of C:\WindowsAzurePHPApp\WindowsAzurePHPApp_WebRole\ moved into C:\temp\WindowsAzurePHPApp\PhpOnAzure.Web

Do that and report back with any issues you may have encountered.

Dec 1, 2011 at 2:01 PM

@blobaugh: Thx for your quick response. Now it almost works for me. My problem was solved by re-installing PHP with the Web Platform Installer.

I have another question about the php.ini wihtin the WebRole. I know that the main stettings are coming from:

C:\Program Files (x86)\PHP\v5.3\php.ini

And that they can be enhanced and/or overridden by:

C:\temp\WindowsAzurePHPApp\PhpOnAzure.Web\php\php.ini

But when I try to add the extension php_pdo_odbc.dll:

[PhpAzureChanges]
extension=php_pdo_odbc.dll

it does not work. The custom php.ini seams to be ignored, even if I put the dll into the custom php\ext folder.

do you know why?

Editor
Dec 1, 2011 at 3:35 PM

aurelious,

This is an oddity with the emulator. In an ideal world the emulator would setup a completely isolated environment that acts just like Windows Azure, however this is not the way it works. The environment the emulator runs still utilizes your local PHP, IIS, environment variables, etc. So to get the functionality you are looking for you need to add to the local PHP install and also the custom PHP setup in the project.

Ben

Dec 2, 2011 at 9:32 AM

Hi Ben,

sorry for nerving you with my questions, but we are now a little in trouble because the deployment cycle of our production system is frozen since this SDK update, which causes deep structural chances.

...to get the functionality you are looking for you need to add to the local PHP install and also the custom PHP setup in the project.

Ok, but then I don't understand the sense of the custom PHP folder within the project.

This also means, that I need to modiy the bin/install-php... scripts.

Editor
Dec 2, 2011 at 6:01 PM

Do you need to run custom PHP extensions or php.ini settings in Windows Azure? Your local settings are local so they will not be available in your app when it is on Windows Azure, therefore any customization you need you must tell your package about so that they will be setup when running in Windows Azure.

I do not understand why you would need to modify the bin/install-php scripts. Could you explain your reasoning more?

If you need to take more control of PHP than the scaffolder affords you you may want to look into packaging PHP with your application instead of using the install on Windows Azure:
http://blogs.msdn.com/b/silverlining/archive/2011/11/23/packaging-a-custom-php-installation-for-windows-azure.aspx

Cheers,
Ben

Dec 2, 2011 at 7:48 PM

Hi, thx for the link, very interessting. I already did it almost like Brain. PHP works now. The rest of the problems are in my PHP code because some $_SERVER vars have changed. E.g. $_SERVER['RoleRoot'] or $_SERVER['INSTANCE_ID']. Do know how far it is possible to trust the $_SERVER-vars in the future? I noticed that they change sometimes or disappear from SDK update to SDK update.

Editor
Dec 2, 2011 at 10:56 PM

They should _never_ disappear. If you see something that was not previously marked as deprecated gone please post a report in the Issue Tracker. Anything disappearing will break applications :(

Ben

Dec 5, 2011 at 1:39 PM
Edited Dec 5, 2011 at 1:55 PM

There are 4 changes/differences with the new SDK that killed my application:

  • $_SERVER['RoleRoot'] doesn’t exist anymore.
  • $_SERVER['INSTANCE_ID'] doesn’t contain a local Instance number like “1″ or “2″ anymore. It seams that it’s now a global number like “16325987″.
    Alternativly you can use [RoleInstanceID] => WebRole_IN_0.
  • $_SERVER['TEMP'] is not the same drive like the accessable local storage any more, so you can’t use it to locate the current letter of the this drive. I don’t know if it’s always “c:\“.
  • The PHP method azure_getconfig(‘StorageAccountName’) does not exist anymore. This method could be used to get the setting values of the ServiceConfiguration.cscnf.
    Even if I copy the php_azure.dll of the old project into the new one and enabling the extension (extension=php_azure.dll) within the php.ini, it does not work.

(I discribed all steps of the Windows Azure SDK 1.6 and PHP migration progress here)

Editor
Dec 5, 2011 at 4:50 PM

aurelious,

Please create a bug report for the $_SERVER variables that are missing.

azure_getconfig('StorageAccountName') still works, however it is dependent upon those values existing in the ServiceConfiguration.cscfg file. If StorageAccountName is not defined azure_getconfig will not be able to find it.

Ben

Dec 5, 2011 at 5:05 PM

Hi Ben,

do you use a different EXT-DLL, or how do you get the special azure_getconfig function? In my case it doesn't work (StorageAccountName is definitely defined)...

The Tickets are created.

Editor
Dec 5, 2011 at 5:10 PM

aurelious,

I use the php_azure.dll. If it is definitely defined could you please post the snippet from your config file showing it defined along with a code snippets showing use to the issue tracker for that project?

http://phpazurecontrib.codeplex.com/

Ben