Configure the entry point script for an Azure function

I am using a Docker image as my function app container and one thing I want to configure is the path to the entry point of the function app. It is function_app.py in v2 programming model. I am wondering whether there is a way to specify the path or name to such a entry point file.

I hope the entry file path or name can be configurable.

New contributor

EMMA LYU is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

3

You can run the Python Azure function without mentioning EntryPoint in Dockerfile.

I have created a Python V2 Azure function.

Dockerfile:

FROM mcr.microsoft.com/azure-functions/python:4-python3.11

ENV AzureWebJobsScriptRoot=/home/site/wwwroot 
    AzureFunctionsJobHost__Logging__Console__IsEnabled=true

COPY requirements.txt /
RUN pip install -r /requirements.txt

COPY . /home/site/wwwroot
  • The entry point for the docker container is managed by the Azure Functions runtime which is specified in the base image in Docker file mcr.microsoft.com/azure-functions/python:4-python3.11.

  • The function runtime looks for the function files in /home/site/wwwroot directory, where the application code is copied to by the COPY . /home/site/wwwroot command.

  • When you run docker run locally, the Azure Functions runtime starts up and look for the function definitions in the /home/site/wwwroot directory and manages the execution of the functions based on the triggers (Http, Timer etc.,) defined.

function_app.py:

app = func.FunctionApp()

@app.route(route="http_trigger", auth_level=func.AuthLevel.ANONYMOUS)
def http_trigger(req: func.HttpRequest) -> func.HttpResponse:
    logging.info('Python HTTP trigger function processed a request.')

    name = req.params.get('name')
    if not name:
        try:
            req_body = req.get_json()
        except ValueError:
            pass
        else:
            name = req_body.get('name')

    if name:
        return func.HttpResponse(f"Hello, {name}. This HTTP triggered function executed successfully.")
    else:
        return func.HttpResponse(
             "This HTTP triggered function executed successfully. Pass a name in the query string or in the request body for a personalized response.",
             status_code=200
        )

Build the docker image:

Command: docker build -t <Image_Name> .
C:Usersunamepydockerfn>docker build -t <Image> .
[+] Building 1.1s (9/9) FINISHED                                                                                docker:desktop-linux
 => [internal] load build definition from Dockerfile                                                                            0.1s
 => => transferring dockerfile: 466B                                                                                            0.1s
 => [internal] load metadata for mcr.microsoft.com/azure-functions/python:4-python3.11                                          0.5s
 => [internal] load .dockerignore                                                                                               0.1s
 => => transferring context: 59B                                                                                                0.0s
 => [1/4] FROM mcr.microsoft.com/azure-functions/python:4-python3.11@XX256:51353837a9b2830XXXd0cc713016da2a6f4bc5  0.0s
 => [internal] load build context                                                                                               0.0s
 => => transferring context: 701B                                                                                               0.0s
 => CACHED [2/4] COPY requirements.txt /                                                                                        0.0s
 => CACHED [3/4] RUN pip install -r /requirements.txt                                                                           0.0s
 => CACHED [4/4] COPY . /home/site/wwwroot                                                                                      0.0s
 => exporting to image                                                                                                          0.1s
 => => exporting layers                                                                                                         0.0s
 => => writing image XX256:7311206332f492a6b1cXXXb684eebd0f4740ec14df5169b                                    0.0s
 => => naming to docker.io/<Image>          

Run the image in local container:

Command: docker run -p 8080:80 <Image_Name>
C:Usersunamepydockerfn>docker run -p 8080:80 -it pravallikakv/pydocerfn

WEBSITES_INCLUDE_CLOUD_CERTS is not set to true.
info: Host.Triggers.Warmup[0]
      Initializing Warmup Extension.
info: Host.Startup[503]
      Initializing Host. OperationId: 'fc439677-86bb-4fa7-b088-ba76773ec9b5'.
info: Host.Startup[504]
      Host initialization: ConsecutiveErrors=0, StartupCount=1, OperationId=fc439677-86bb-4fa7-b088-ba76773ec9b5
info: Microsoft.Azure.WebJobs.Hosting.OptionsLoggingService[0]

//Removed few logs

info: Host.Startup[412]
      Host initialized (164ms)
info: Host.Startup[413]
      Host started (199ms)
info: Host.Startup[0]
      Job host started
Hosting environment: Production
Content root path: /azure-functions-host
Now listening on: http://[::]:80
Application started. Press Ctrl+C to shut down.
info: Host.General[337]
      Host lock lease acquired by instance ID '0000000000000000000000009ED2BB0B'.
info: Function.http_trigger[1]
      Executing 'Functions.http_trigger' (Reason='This function was programmatically called via the host APIs.', Id=f013216f-aecd-4a4d-b924-4263c153440e)
info: Function.http_trigger.User[0]
      Python HTTP trigger function processed a request.
info: Function.http_trigger[2]
      Executed 'Functions.http_trigger' (Succeeded, Id=f013216f-aecd-4a4d-b924-4263c153440e, Duration=159ms)

Recognized by Microsoft Azure Collective

2

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật