Tutorial: Publishing Hello COBOL World to the Cloud

Note: Before starting this tutorial you need to have the prerequisite software for using Microsoft Azure within Visual COBOL installed. See Additional Software Requirements for details.

In this tutorial you create a "Hello COBOL World" cloud service which you then deploy and run under Microsoft Azure.

The main steps are:

  1. Create a COBOL cloud solution, comprising a cloud service and a web role.
  2. Add the "Hello COBOL World" code to the web role.
  3. Run the service in the compute emulator and debug it.
  4. Publish and deploy the service to the cloud.
  5. View the service running on the cloud.
  6. Tidy up in Microsoft Azure

Create a COBOL Cloud Solution

First, create a COBOL cloud solution using the COBOL cloud template in the IDE, and choose a web role only, as follows:

  1. Run Visual Studio as administrator. To do this, go to Start > All Programs > Micro Focus Visual COBOL, right-click Visual COBOL for Visual Studio 2015 and click Run as administrator.
  2. Click File > New > Project.
  3. Expand COBOL and click Cloud. After clicking Cloud, the option Azure Cloud Service should be displayed. If the option Enable Windows Azure Tools is displayed instead, you do not have the prerequisite software for Microsoft Azure. If this is the case, select Enable Windows Azure Tools and click OK to access the Microsoft web site from where you can download the software that you need to install. See Additional Software Requirements for information on the Microsoft Azure software that is required.
  4. Enter a name for your project, such as "Hello COBOL World" and enter a name and location for your solution. Click OK.
  5. Choose ASP.NET Web Role to create just a web role. Click > and then OK.

The newly-created solution contains two projects: one for the cloud service and one for the web role. The service project contains the service configuration and definition files, and also an association with the web role. You can see all this in Solution Explorer.

Edit the Code in the Web Role

For this simple service just add the "Hello COBOL World" text, as follows:

  1. In the web role project, open the Default.apsx file.
  2. In the Designer view, add some text such as Hello COBOL World. You could also add buttons and other UI controls from the Toolbox.
  3. Save the file.

Run and Debug the Service

Now you can build the solution and start testing it locally in the compute emulator, as follows:

  1. Build the solution. You can do this from the Build menu.
  2. Start debugging. You can do this from the Debug menu.

    This starts the compute emulator, which is the local development environment. The compute emulator might take some time to start up the first time you run the application.

    Your application then runs and, if appropriate, the web browser opens and displays your web page.

  3. Show the compute emulator UI. To do this, right-click the Microsoft Azure Emulator icon in the Windows taskbar or notification area, and click Show Compute Emulator UI.

    In the compute emulator, monitor your application while it is running and start and stop it as necessary. You can see your trace messages in the compute emulator and verify the application's basic functionality.

Publish and Deploy to Microsoft Azure

Before you deploy your service to the cloud, you must create a Microsoft Azure account. In addition, before you deploy directly from Visual Studio, you need to create the following items that enable Visual Studio to authenticate your credentials with Microsoft Azure:

  • A Microsoft Azure subscription
  • A Microsoft Azure cloud service
  • A Microsoft Azure storage account

You create your account and the above items through the Microsoft Azure Management Portal.

To publish and deploy to Microsoft Azure:

  1. Publish your solution, by clicking Build > Publish Solution-name. If this is the first time you have deployed anything to Microsoft Azure, the Choose your subscription drop-down list will not contain any entries. If this is the case, click Sign in to download credentials to create and download a file containing your Microsoft Azure account credentials. When you have downloaded that file, click Import to load it, and your Microsoft Azure subscription details will then be listed in the Choose your subscription drop-down list.
  2. Ensure the required Microsoft Azure subscription is selected in the Choose your subscription drop-down list, and click Next.
  3. Ensure that the settings shown are correct for the Microsoft Azure setup you want to use, and click Next.
  4. Confirm that the details shown by the publish summary are correct for the Microsoft Azure setup you want to use, and click Publish.
The Microsoft Azure Activity Log shows the publication and deployment status. Deployment could take a few minutes.

View the Service Running on the Cloud

Once you have deployed your service you can see it running on the cloud. It should look exactly as it did when you debugged it using the compute emulator.
  1. In the Microsoft Azure Activity Log, expand the entry for the deployment of your service. Various information is displayed about the service and its status.
  2. Click the link beneath the Website URL heading. A web browser opens and displays your web page. It should look exactly as it did when you debugged it using the compute emulator.

Tidy up in Microsoft Azure

Once you're no longer using your service you need to stop its deployment and delete it from Microsoft Azure or you will continue to be billed for it when you are not using it. After you have stopped and deleted the deployment, if you need to run the service in Microsoft Azure again you can easily publish and deploy it again.
  1. Stop the deployment. This stops the deployment but you are billed for each role instance, even when a deployment is stopped.
  2. Delete the deployment.