我不断收到错误消息
ModuleNotFoundError:没有名为“azure”的模块
对于第 4 行,下面是使用本教程import azure.functions as func
设计的初始化文件的代码
import logging
import azure.functions as func
def main(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"Hellod {name}!")
else:
return func.HttpResponse(
"Please pass a name on the query string or in the request body",
status_code=400
)
Run Code Online (Sandbox Code Playgroud)
对此的任何帮助将不胜感激!
Azure 函数中的构造函数注入和自定义遥测事件的集合需要此非静态类。
如果我们在 Visual Studio 中创建一个 azure 函数应用程序,它会使用 static 关键字创建默认值,如下所示:
public static async Task<IActionResult> Run(
[HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = null)] HttpRequest req,
ILogger log)
{
telemetryClient.TrackEvent(new Exception("Function started"));
}
Run Code Online (Sandbox Code Playgroud)
但是要使用构造函数依赖注入(对于 Temeltry 客户端,我正在使用它),我们需要删除 static 关键字。
public Function1(TelemetryClient telemetryClient)
{
_telemetryClient = telemetryClient;
}
Run Code Online (Sandbox Code Playgroud) 我当前的设置:
我的 DevOps 人员创建了一个用户管理身份并将其添加到 Azure key Vault 的访问策略中。
我创建了一个函数应用程序testing-01,并在平台设置下为其分配了 User-ManagedIdentity。
我使用 Python 3.6 作为运行时语言。
这是我的辅助方法,我用它来检查是否能够从密钥保管库访问秘密。我正在回复它的回复。
def cred_checker():
credential = ManagedIdentityCredential()
# credential = ManagedIdentityCredential(client_id='client_id
vault_name= "myvault"
client = SecretClient(vault_url=f"https://{vault_name}.vault.azure.net/", credential=credential)
username = client.get_secret(name="username")
password= client.get_secret(name="password")
return f"AKV client created successfully {client} .<br> name: {username},<br> pass: {password} "
Run Code Online (Sandbox Code Playgroud)
我能够毫无错误地创建客户端。但是当我尝试从中获取机密时,我收到此 ClientAuthenticationError :
Exception while executing function: Functions.HttpTriggerFunc <--- Result: Failure Exception: ClientAuthenticationError: Unexpected response '{'statusCode': 400, 'message': 'Unable to load requested managed identity.', 'correlationId': '92daf146-fed2-4a75-8359-9r955939815e'}'
Run Code Online (Sandbox Code Playgroud) python azure azure-functions azure-managed-identity azure-function-app
想问一下有没有可以获取Azure SignalR连接字符串的ARM模板函数。
我已经在 Azure 的消费计划上创建了一个 Azure Function App。在消耗计划中,需要配置设置 WEBSITE_CONTENTSHARE。然而,似乎有人删除了这个值。(它通常采用“我的函数名称后缀”形式,其中“后缀”是某个字符串值)。
如何找到 Azure 中的实际共享位置,以便可以将此值恢复到配置设置?
最近,在我们的一些部署中,关于如何自动化功能应用程序和 Web 应用程序的应用程序设置,内部存在一些混乱,并且检查周围似乎有大量令人眼花缭乱的选项,看起来它们在做大致相同的事情,但在不同的地方脚步。
我们的开发人员通常有一个提交到存储库的 appsettings.json 文件,对于他们的测试来说可能看起来像这样......
{
"Logging": {
"LogLevel": {
"Default": "Information",
}
},
"Values": {
"ThingToPointTo": "http://localhost",
}
}
Run Code Online (Sandbox Code Playgroud)
当我们将其带到其他环境(例如 PROD)时,我们将ThingToPointTo更改为“https://productservice”之类的内容
我们一直在使用 Azure DevOps YAML 管道以这种方式部署和更改 AppSettings...
- task: AzureFunctionApp@1
inputs:
azureSubscription: 'OurAzureSubServiceConnection'
appType: functionApp
appName: $(azfuncappname)
package: '$(Pipeline.Workspace)/drop/$(Build.BuildId).zip'
AppSettings: '-Values:ThingToPointTo "https://productionservice"'
Run Code Online (Sandbox Code Playgroud)
我的问题有两个
Values :ThingToPointTo是否正确枚举到正确的设置,或者应该只是ThingToPointTo(省略Values:)?
这是这样做的方法吗?我注意到您可以在部署之前使用 JSON 转换步骤来更改实际文件,并且还有一个名为“Azure 应用服务设置”的任务可以在部署后使用它来执行此操作?
关于这个主题的文章有很多,但似乎没有一篇适合。
提前致谢!
azure azure-web-app-service azure-devops azure-pipelines azure-function-app
我已经构建了一个 Azure 函数。我可以直接从 Visual Studio(右键单击项目,然后“发布”)将其部署到我的 Azure FunctionApps,没有任何问题。但是,当我尝试使用 Azure DevOps 构建和部署它时,我收到以下错误,但我不知道这意味着什么。我什至不知道什么是Kudu?
The network path was not found.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.IO.IOException: The network path was not found.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception …Run Code Online (Sandbox Code Playgroud) 我在 Nodejs 版本 12 中创建了一个 Azure Function 应用程序。我的托管环境是 Windows。捕获保存在我的函数内的 Azure 密钥保管库中的用户名和密码的最简单方法是什么。另外,我正在使用内联代码编辑器,因此应该如何捕获代码中的凭据。
谢谢
azure azure-node-sdk azure-keyvault azure-functions azure-function-app
在我的 Azure 解决方案中,我有 1 个应用程序服务和 2 个功能应用程序记录到 1 个应用程序洞察实例。在特定环境中,我想减少日志记录负载,因此我想摆脱严重性级别 0 的日志。
我目前专注于其中一个功能应用程序,我们将其称为 fa1。我使用 ILogger 添加为 LogDebug 的日志记录语句不会按预期显示在应用程序见解中。但是我可以在应用程序见解中看到以下条目:
我还看到以下条目,但我不知道哪个服务正在生成它们:
主机.json:
{
"version": "2.0",
"logging": {
"applicationInsights": {
"samplingSettings": {
"isEnabled": true,
"excludedTypes": "Request"
}
},
"logLevel": {
"Function": "Warning",
"default": "Warning"
}
}
}
Run Code Online (Sandbox Code Playgroud)
启动.配置():
builder.Services.AddLogging(loggingBuilder =>
{
var key = Environment.GetEnvironmentVariable("APPINSIGHTS_INSTRUMENTATIONKEY");
loggingBuilder.AddApplicationInsights(key);
});
builder.Services.AddSingleton(sp …Run Code Online (Sandbox Code Playgroud) 目前,Microsoft 引入了一种处理 Azure 函数的新方法,称为隔离进程,它是在 .NET5 上运行 Azure 函数的唯一方法。
我正在尝试通过 Azure DevOps 将已在本地计算机上正确运行的函数应用程序部署到 Azure Func 应用程序。部署成功,但是功能不起作用。
首先在部署任务中我看不到 .NET 5,如下所示:
但我可以在此处的链接中看到支持 .NET 5 作为预览版:
https://learn.microsoft.com/en-us/azure/azure-functions/functions-versions#languages
部署后,我可以看到以下错误:
但我将配置更改为:
该函数还显示了此错误:
我还可以从这里看到该函数已在 .NET 5 上运行:
所以不确定如何正确部署它。我知道隔离的进程功能只需要 azure 功能工具 + 运行命令行,所以不确定如何部署它,而且 Microsoft 没有任何关于如何部署它的教程或文档?
azure azure-devops azure-functions azure-function-app .net-5