简体   繁体   中英

Play 2: How to deploy dist app to the Windows Azure Cloud Services (not VM)

Question: What is the way for deploying Play app to the Windows Azure Cloud Services (not the Virtual Machine)?

Background: I need to deploy small application to the Azure and I'd like to do that with common dist packaging method (it creates folder with all required *.jar files + start script that can be run on any system with the JDK installed). Need to add that I wouldn't like to use Starter Kit for Java + WAR packaging as... I'm working on so I would need to buy/lean next machine with Windows just for this one task (The Kit works on Win only).

Unfortunately I have no experience with Azure's services. If I mixed things too much or if it's impossible without WAR + Kit please let me also know ;)

For the Devoxx conference here in Belgium, Steve Marx created a Scala app with the Play framework that runs on Windows Azure. Instead of using the Starter Kit for Java, this uses packageanddeploy (simple scaffold that packages an Azure app).

Read through his blog post ' Using Scala and the Play Framework in Windows Azure ' or take a look at the project on github .

But there's one little issue, this also uses the cspack.exe for which I think there's no alternative on Mac. cspack is used to create a package you'll deploy to Windows Azure. Now I don't think this is a show stopper.

In his blog post, Steve talks about the WorkerRole\\downloadstuff.ps1 file that downloads Java and the Play framework. You could extend it to also download your application (packed in a zip file). This way, your package will be very static (just a few scripts, which will download the acutal application), and you won't need to run cspack each time you want to deploy.

Now if you don't want to buy a Windows machine, you could do the following:

  1. Based on Steve's blog post, modify downloadstuff.ps1 to also download your app from blob storage.
  2. Upload your app to blob storage
  3. Create a Virtual Machine
  4. Connect using RDP to that VM and install the Azure SDK, tools, ...
  5. Create a package using cspack (look in the packageanddeploy project) to create a static package that contains all the scripts.
  6. Delete the VM, now that you have the package you'll no longer need it
  7. Deploy the package to a cloud service, this will run your scripts, trigger the download of your app and you'll have a running app.
  8. Each time you want to deploy, you'll simply upload the new version of your app to the storage account and you'll redeploy the static package, without having to use Windows

As far as I know, Cloud Service (PaaS) package can only be made from Windows, so currently Windows machine is a requirement.

Visual Studio is probably the easiest tool to create your own Cloud Service but you will need to learn VS and non standard way to make Azure app. This can be quite an investment.

You can do cmd installed and started application (not only WAR base Java EE application) from the Azure plugin in Eclipse. If you already know Eclipse this can be a quick way to build a Cloud Service Package.

If you chose the Eclipse way, you can build your own application image this way:

  1. Create a new Azure project, don't specify the application server and the JVM.
  2. Look at the example start-up script (basically it unzip the jvm, application server, move the war in the deploy folder and start the application server). The step for an application server and other application are similar: install and start it, the startup.cmd file can do it for your application.
  3. Make similar script to install your application: unzip the jvm, the application or the package manager. Put every element in the right place and then start your applicaton (don't forget to call it via start command to make sure the start-up script to finish)

When you understand how it works, you should try to make your Azure package more flexible by putting the archive in Blob support and download them during start up. This will increase development efficiency trust me. In a second step you can make the start-up script configurable by downloading some other script or configuration file you can specify in the ServiceConfiguration.csfg file allowing you to limit the boot of you Windows machine...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM