在容器的Azure Web应用程序上运行非WEB应用程序容器

发布于 2025-02-07 23:43:57 字数 1004 浏览 1 评论 0原文

我正在尝试在Azure中启动一个不断运行的容器,该容器从队列中读取并使用某些应用程序代码处理消息。为此,我想将 Azure Web应用程序用于容器。尽管我知道这不是最明显的选择,因为我的容器没有运行Web应用程序,但我想知道是否可以使其可行。

我通过一个非常简单的python脚本模拟了A的设置:

if __name__ == '__main__':
    logging.basicConfig(level=logging.INFO)
    count = 0
    while True:
        time.sleep(30)
        count += 30
        logging.info(f'Busy counting: {count}')

我可以在带有以下内容的Docker映像中制作可召唤:

FROM python:3.8-slim-buster
COPY main.py /app/main.py
WORKDIR /app
EXPOSE 80
    
CMD ["python", "./main.py"]

我将此映像设置为要在Web App服务中使用的映像,之后启动了容器。我将日志记录到230秒之前,然后将容器停止以下日志

2022-06-16T14:46:34.582Z ERROR - Container testapp_123 for site testapp did not start within expected time limit. Elapsed time = 230.9588354 sec

::

Container testapp_123 didn't respond to HTTP pings on port: 80, failing site start. See container logs for debugging.

消息 在没有Web服务器运行的情况下,从发生或运行我的应用程序中的ping,还是基本上不可能实现?

I'm trying to launch a constantly running container in Azure that reads from a queue and processes the messages with some application code. To do so, I want to use Azure Web App for Containers. Although I know this is not the most obvious choice since my container doesn't run a web app, I would like to know if this could be made to be workable.

I mocked the setup of a by a very simple Python script:

if __name__ == '__main__':
    logging.basicConfig(level=logging.INFO)
    count = 0
    while True:
        time.sleep(30)
        count += 30
        logging.info(f'Busy counting: {count}')

which I make callable in a Docker image with the following content:

FROM python:3.8-slim-buster
COPY main.py /app/main.py
WORKDIR /app
EXPOSE 80
    
CMD ["python", "./main.py"]

I set this image as the image to use in the Web App Service, after which the container is launched. I get the logging up until 230 seconds, after which the container is stopped with the following log message:

2022-06-16T14:46:34.582Z ERROR - Container testapp_123 for site testapp did not start within expected time limit. Elapsed time = 230.9588354 sec

and:

Container testapp_123 didn't respond to HTTP pings on port: 80, failing site start. See container logs for debugging.

Now this obviously has to do with the fact that I have no web server listening on port 80. Is there any way to circumvent this pinging from even happening or running my app without a web server running, or would this be basically impossible to achieve?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文