Hot questions for Using Azure in azure cloud services

Top Java Programmings / Azure / azure cloud services


When Azure shuts down a Cloud Service instance (e.g. when the host OS reboots, or when autoscaling down), it triggers a Stop method, so applications have a chance to gracefully shutdown.

I can find documentation how to do this in .NET: but I cannot find any documentation on how to do this from Java.

How can I do this in Java?



This is available from Maven Central:||azure-serviceruntime|0.6.0|jar


How to get Cloud Service (Hosted Service) diagnostic data using Java or Rest API?

We can get DiagnosticsConnectionString from Azure Portal for Roles and using which we can query to WADPerformanceCounter Table (Storage API).

Getting following exception while executing:

query:java.util.NoSuchElementException: An error occurred while enumerating the result, check the original exception for details. at‌​xt(LazySegmentedIter‌​ at TestStorage.main( Caused by: Bad Request


@Prit, There is not any code in your question so that I couldn't figure out the issue which was caused by what.

So I post my steps and code here as reference for helping.

  1. Copy the DIAGNOSTICS CONNECTION STRINGS of one role of the Cloud Service at the tab CONFIGURE of Cloud Service on Azure Management portal, the format of conection string is like DefaultEndpointsProtocol=https;AccountName=<storage-account-name>;AccountKey=<storage-key>.

  2. Use the GUI tool Micorsoft Azure Storage Explorer to find & view the table WADPerformanceCounter.

  1. Code in Java to retrieve all diagnostic data as below.

    public class WADPerformanceCounterReader {
        public static final String storageConnectionString = 
        public static void main(String[] args) {
            try {
                // Retrieve storage account from connection-string.
                CloudStorageAccount storageAccount = CloudStorageAccount.parse(storageConnectionString);
                // Create the table client.
                CloudTableClient tableClient = storageAccount.createCloudTableClient();
                CloudTable cloudTable = tableClient.getTableReference("WADPerformanceCountersTable");
                TableQuery<TableServiceEntity> query = TableQuery.from(TableServiceEntity.class);
                for (TableServiceEntity entity : cloudTable.execute(query)) {
            } catch (Exception e) {
                // Output the stack trace.

Hope it helps.


My Azure Web Role has R,Java etc configured on it automatically before my actual application starts running. Everything configures perfectly fine and the application is running smoothly. I have had no problem with my web app for 2 weeks and it was working fine in an Azure Web Role. Then one day while I was opening my web app I faced an error related to R-core. On remotely accessing my Azure VM, I found out that my R,Java and R packages were deleted. Going through the event viewer I found out that my Azure VM was restarted 3times.

It is an ASP.NET web app hosted in IIS on an Azure Web Role.

After the whole scenario, could you please direct me about Web Role Recycling. When its working fine for 2 weeks how come it recycles itself and deletes my installations ?


Microsoft periodically upgrades the host OS, guest OS, and guest agent hosting the cloud service. Your VM will be rebooted during this time (or guest agent restarted). Cloud services are "stateless", meaning in this case that any prerequisites you have for running your application must be installed via a start-up script.

For more details see: