简体   繁体   English

从 java SDK 禁用 Azure function

[英]disable Azure function from java SDK

Im trying to disable an Azure serverless function by using the java client for Azure. the request seems to return without any errors, but the change is not actually applied.我试图通过使用 Azure 的 java 客户端来禁用 Azure 无服务器 function。请求似乎没有任何错误地返回,但实际上并没有应用更改。 also, a link for decent documentation for the serverless java client (AzureResourceManager) with examples will be nice.此外,带有示例的无服务器 java 客户端 (AzureResourceManager) 的体面文档链接也很好。

FunctionApp functionApp = azureResourceManager.functionApps().getById(functionId);
FunctionEnvelope f11 = functionApp.listFunctions().stream().findFirst().get();
f11.innerModel().withIsDisabled(true);
functionApp.update().apply();

To disable a function, you can use the withIsDisabled method of the FunctionProperties class to set the isDisabled property to true.要禁用 function,可以使用 FunctionProperties class 的 withIsDisabled 方法将 isDisabled 属性设置为 true。 This method returns a new instance of the FunctionProperties class with the updated property, so you will need to update the function using this new instance.此方法返回具有更新属性的 FunctionProperties class 的新实例,因此您需要使用此新实例更新 function。

Here is an example of how you can disable a function using the Azure Resource Manager Java client:以下是如何使用 Azure 资源管理器 Java 客户端禁用 function 的示例:

FunctionApp functionApp = azureResourceManager.functionApps().getById(functionId);
FunctionEnvelope f11 = functionApp.listFunctions().stream().findFirst().get();
FunctionProperties updatedProperties = f11.innerModel().withIsDisabled(true);
functionApp.update().withFunctionProperties(updatedProperties).apply();

found the following solution.找到了以下解决方案。 the function enable/disable property is actually an app setting field of the function app. function enable/disable 属性实际上是function 应用的一个应用设置字段。 we need to add this configuration to the function app:我们需要将此配置添加到 function 应用程序:

    functionApp.update().withAppSetting("AzureWebJobs.<function_name>.Disabled", "1").apply();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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