用于基于 Python 的可扩展性操作的 Azure 日志记录

现在,可以在可扩展性操作脚本中使用 Microsoft Azure 3.x 日志记录函数。
Automation Assembler
中的可扩展性操作现在使用
Microsoft Azure
3.x 脚本 API,替代了以前的 1.x 版本。
Microsoft Azure
3.x 脚本 API 基于 Linux,在容器环境中运行。
由于这一版本更改,将
Microsoft Azure
用作 FaaS(功能即服务)提供程序的可扩展性操作脚本中插入的日志记录函数以不同的方式运行。以下两个脚本示例演示了两个 API 版本中使用的不同日志记录函数。
Microsoft Azure
1.x 脚本示例。
def handler(context, inputs): greeting = "Hello, {0}!".format(inputs["target"]) print(greeting) outputs = { "greeting": greeting } return outputs
Microsoft Azure
3.x 脚本示例。
import logging def handler(context, inputs): greeting = "Hello, {0}!".format(inputs["target"]) logging.info(greeting) outputs = { "greeting": greeting } return outputs
以上实例演示 3.x 版本在脚本的开头添加了
import logging
函数,同时将
print()
函数替换为了
logging.info()
函数。要继续在 Microsoft Azure 1.x API 中创建的可扩展性操作中使用日志记录,必须更改脚本中的日志记录函数,以便与
Microsoft Azure
3.x 示例匹配。
有关日志记录的详细信息,请参见 Azure Functions Python 开发人员指南