Azure / Azure/azure-libraries-for-java

Add VM extension fails to execute using async methods

Open
#710 7 comments 0 reactions 1 assignee Assigned to @ChenTanyi View on GitHub
Compute - VM customer-response-expected Mgmt needs-more-info
Dominant language
Java
Stars
97
Forks
102
PR merge metrics
No merged PRs in 30d

Description

This is related to [ticket](https://github.com/Azure/azure-libraries-for-java/issues/632). I followed the guide to add a VM extension but instead of executing this synchronously I used the applyAsync methods instead.

This is the guide that I followed:
https://github.com/Azure-Samples/compute-java-manage-virtual-machine-using-vm-extensions/blob/master/src/main/java/com/microsoft/azure/management/compute/samples/ManageVirtualMachineExtension.java

As I don't care about the result and don't want to wait for a response, I pass in a null ServiceCallback. This is the same approach I've seen used elsewhere and is working for both VirtualMachine#startAsync and VirtualMachine#powerOffAsync. This fails to send any HTTP requests. If I execute this synchronously I see the HTTP requests going through as expected.

I could be doing something wrong, but the same approach does work for other methods.

Approach for applyAsync that doesn't work:

` virtualMachine.inner().withPlan(null);
virtualMachine.update().defineNewExtension("OMSExtension").withPublisher("Microsoft.EnterpriseCloud.Monitoring")
.withType("OmsAgentForLinux").withVersion(OMS_AGENT_VERSION).withMinorVersionAutoUpgrade()
.withPublicSetting("workspaceId", workspaceId).withProtectedSetting("workspaceKey", workspaceKey)
.attach().applyAsync(null);`

Approach for powerOffAsync that does work:
`virtualMachine.powerOffAsync(null);`

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.