如何使用Java SDK在Azure批处理中设置默认应用程序版本

时间:2019-04-15 16:24:53

标签: azure azure-batch

有没有一种方法可以使用Java SDK在Azure批处理帐户中设置默认应用程序版本? 他们在git中拥有的示例脚本没有显示如何设置默认版本(https://github.com/Azure-Samples/batch-java-manage-batch-accounts/blob/master/src/main/java/com/microsoft/azure/management/batch/samples/ManageBatchAccount.java)。

我还试图在界面(https://github.com/Azure/azure-libraries-for-java/blob/master/azure-mgmt-batch/src/main/java/com/microsoft/azure/management/batch/Application.java)中挖掘一些线索,但是看不到任何支持更新默认版本的东西。

更新:

我能够按照@brklein的建议进行版本更新:

BatchApplication batchApplication = batchAccount.applications().get(applicationName)
ApplicationTokenCredentials credentials = new ApplicationTokenCredentials(applicationId, tenantId, appSecret, AzureEnvironment.AZURE)
BatchManager batchManager = BatchManager.authenticate(credentials, subscriptionId)
ApplicationsInner applicationsInner = batchManager.inner().applications()
ApplicationUpdateParameters parameters = new ApplicationUpdateParameters(defaultVersion: DEFAULT_APP_VERSION)
applicationsInner.update(resourceGroupName, batchAccountName, batchApplication.id(), parameters)

1 个答案:

答案 0 :(得分:1)

似乎没有默认版本出现在SDK的客户端层上。

要解决此问题,您应该能够手动调用实现方法,这些方法具有REST API的全部功能(因为它们是自动生成的)。 为此,请创建CreateApplicationParametersApplicationUpdateParameters并设置defaultVersion属性。然后,您可以调用实现手动创建或更新方法(https://github.com/Azure/azure-libraries-for-java/blob/78e8ff2940eba34bc63f8e7be6807a377500f5c7/azure-mgmt-batch/src/main/java/com/microsoft/azure/management/batch/implementation/ApplicationsInner.java#L474)。