简体   繁体   English

Azure WebJob在同一主机上调用WebAPI

[英]Azure WebJob calling WebAPI on same host

I have a WebJob which calls API endpoints on the same host. 我有一个WebJob,它在同一主机上调用API端点。 As per samples on I've gathered the HttpClient requires the complete URL and the host address is set through configuration. 根据我收集的样本,HttpClient需要完整的URL,并且主机地址是通过配置设置的。 I want a mostly configuration-less setup and have the webjob calling the localhost. 我想要一个几乎不需要配置的设置,并让webjob调用localhost。 Is it possible to use: 是否可以使用:

  • https://localhost ? https:// localhost
  • Figure out the server url by looking at the host details? 通过查看主机详细信息找出服务器URL?
  • Skip the host address and use relative paths? 跳过主机地址并使用相对路径?

Thanks! 谢谢!

ÉB

You cannot use localhost or relative path. 您不能使用localhost或相对路径。

Instead, to get the host name, you can rely on the WEBSITE_HOSTNAME environment variable, which is set to YourSite.azurewebsites.net . 相反,要获取主机名,您可以依靠WEBSITE_HOSTNAME环境变量,该变量设置为YourSite.azurewebsites.net

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

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