当我从门户运行 azure 函数时,我收到以下错误。
错误:{“message”:“无法获取”,“stack”:“TypeError:无法获取 在 https://portal.azure.com/Content/Dynamic/BeUd4hejqUig.js:113:24094","isError":true}
请帮我解决
我的示例代码是
package JWS;
import java.util.*;
import com.microsoft.azure.functions.annotation.*;
import com.microsoft.azure.functions.*;
/**
* Azure Functions with HTTP Trigger.
*/
public class JWSwithRSA {
/**
* This function listens at endpoint "/api/JWSwithRSA". Two ways to invoke it using "curl" command in bash:
* 1. curl -d "HTTP Body" {your host}/api/JWSwithRSA
* 2. curl {your host}/api/JWSwithRSA?name=HTTP%20Query
*/
@FunctionName("JWSwithRSA")
public HttpResponseMessage run(
@HttpTrigger(name = "req",
methods = {HttpMethod.GET, HttpMethod.POST},
authLevel = AuthorizationLevel.FUNCTION)
HttpRequestMessage<Optional<String>> request,
final ExecutionContext context) {
context.getLogger().info("Java HTTP trigger processed a request.");
return request.createResponseBuilder(HttpStatus.OK).body("Welcome ").build();
}
}
在门户中运行函数需要应用程序明确接受来自 https://portal.azure.com 的请求。这称为跨域资源共享 (CORS)。配置 CORS 以将 https://portal.azure.com 添加到允许的来源。