Azure Functions 无法获取主机锁租约:Azure.Storage.Blobs
Azure Functions failed to acquire host lock lease: Azure.Storage.Blobs
我有一个 Azure Function,当 运行 在本地运行时它运行得很好。但是,当我将它部署到 Azure 时,我得到以下信息:
2021-08-18T13:54:49Z [Verbose] Host instance
'cf18298b771b53ee3f905f085f3a7fe0' failed to acquire host lock lease:
Azure.Storage.Blobs: One of the request inputs is out of range.
RequestId:7bc9eccb-601e-0060-0f38-9460f3000000
Time:2021-08-18T13:54:49.2543060Z
Status: 400 (One of the request inputs is out of range.)
ErrorCode: OutOfRangeInput
有什么想法吗?我不知道可能是什么问题
编辑(添加代码):
public partial class Function
{
private readonly IConfiguration _configuration;
private readonly IDataMiner _dataMiner;
private readonly HealthCheckService _healthCheck;
private readonly ILogger<Function> _logger;
private readonly IDatabaseMigrationTool _migrationTool;
private readonly JobOptions _options;
private readonly ITeamsNotificationService _notificationService;
public Function(
ILogger<Function> logger,
IConfiguration configuration,
HealthCheckService healthCheck,
IOptions<JobOptions> options,
IDatabaseMigrationTool migrationTool,
ITeamsNotificationService notificationService,
IDataMiner dataMiner)
{
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
_options = options?.Value ?? throw new ArgumentNullException(nameof(options));
_healthCheck = healthCheck ?? throw new ArgumentNullException(nameof(healthCheck));
_migrationTool = migrationTool ?? throw new ArgumentNullException(nameof(migrationTool));
_dataMiner = dataMiner ?? throw new ArgumentNullException(nameof(dataMiner));
_configuration = configuration ?? throw new ArgumentNullException(nameof(configuration));
_notificationService = notificationService ?? throw new ArgumentNullException(nameof(notificationService));
}
[Singleton]
[FunctionName("MigrateDatabase")]
public IActionResult MigrateDatabase([HttpTrigger(AuthorizationLevel.Anonymous, "get")]
HttpRequest req)
{
string responseMsg;
var connString = _configuration.GetConnectionString(MarketListingDbContext.ConnectionStringName);
_logger.LogInformation($"HTTP trigger function MigrateDatabase connection string: {connString}");
try
{
_migrationTool.Migrate();
responseMsg = "Success";
}
catch (Exception ex)
{
_logger.LogError(ex, ex.Message);
return new BadRequestErrorMessageResult(ex.Message);
}
return new OkObjectResult(responseMsg);
}
[FunctionName("Heartbeat")]
public async Task<IActionResult> Heartbeat(
[HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = "heartbeat")]
HttpRequest request)
{
_logger.LogInformation($"Received heartbeat request\nsettings:\n{_options.ToJson()}");
var status = await _healthCheck.CheckHealthAsync();
return new OkObjectResult(Enum.GetName(typeof(HealthStatus), status.Status));
}
[Singleton]
[FunctionName("MarketListingReport")]
public async Task Report([TimerTrigger("%GenerateReportSchedule%", RunOnStartup = true)] TimerInfo timer)
{
try
{
_logger.LogInformation($"Generating data ingestion report:\n{_options.TeamsConfiguration.ToJsonDebug()}");
await _notificationService.SendNotificationAsync(_options.TeamsConfiguration);
}
catch (Exception ex)
{
_logger.LogError(ex.Message);
throw;
}
}
}
问题可能与区分大小写有关,因为...
- 容器名称中的所有字母都必须小写。
- Blob 名称区分大小写。
检查您的函数设置,确保您的连接字符串、容器名称和 blob 名称正确无误,并且没有任何问题。
有关规则的完整概述,请参阅 Naming and Referencing Containers, Blobs, and Metadata。
我有一个 Azure Function,当 运行 在本地运行时它运行得很好。但是,当我将它部署到 Azure 时,我得到以下信息:
2021-08-18T13:54:49Z [Verbose] Host instance 'cf18298b771b53ee3f905f085f3a7fe0' failed to acquire host lock lease: Azure.Storage.Blobs: One of the request inputs is out of range. RequestId:7bc9eccb-601e-0060-0f38-9460f3000000 Time:2021-08-18T13:54:49.2543060Z
Status: 400 (One of the request inputs is out of range.)
ErrorCode: OutOfRangeInput
有什么想法吗?我不知道可能是什么问题
编辑(添加代码):
public partial class Function
{
private readonly IConfiguration _configuration;
private readonly IDataMiner _dataMiner;
private readonly HealthCheckService _healthCheck;
private readonly ILogger<Function> _logger;
private readonly IDatabaseMigrationTool _migrationTool;
private readonly JobOptions _options;
private readonly ITeamsNotificationService _notificationService;
public Function(
ILogger<Function> logger,
IConfiguration configuration,
HealthCheckService healthCheck,
IOptions<JobOptions> options,
IDatabaseMigrationTool migrationTool,
ITeamsNotificationService notificationService,
IDataMiner dataMiner)
{
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
_options = options?.Value ?? throw new ArgumentNullException(nameof(options));
_healthCheck = healthCheck ?? throw new ArgumentNullException(nameof(healthCheck));
_migrationTool = migrationTool ?? throw new ArgumentNullException(nameof(migrationTool));
_dataMiner = dataMiner ?? throw new ArgumentNullException(nameof(dataMiner));
_configuration = configuration ?? throw new ArgumentNullException(nameof(configuration));
_notificationService = notificationService ?? throw new ArgumentNullException(nameof(notificationService));
}
[Singleton]
[FunctionName("MigrateDatabase")]
public IActionResult MigrateDatabase([HttpTrigger(AuthorizationLevel.Anonymous, "get")]
HttpRequest req)
{
string responseMsg;
var connString = _configuration.GetConnectionString(MarketListingDbContext.ConnectionStringName);
_logger.LogInformation($"HTTP trigger function MigrateDatabase connection string: {connString}");
try
{
_migrationTool.Migrate();
responseMsg = "Success";
}
catch (Exception ex)
{
_logger.LogError(ex, ex.Message);
return new BadRequestErrorMessageResult(ex.Message);
}
return new OkObjectResult(responseMsg);
}
[FunctionName("Heartbeat")]
public async Task<IActionResult> Heartbeat(
[HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = "heartbeat")]
HttpRequest request)
{
_logger.LogInformation($"Received heartbeat request\nsettings:\n{_options.ToJson()}");
var status = await _healthCheck.CheckHealthAsync();
return new OkObjectResult(Enum.GetName(typeof(HealthStatus), status.Status));
}
[Singleton]
[FunctionName("MarketListingReport")]
public async Task Report([TimerTrigger("%GenerateReportSchedule%", RunOnStartup = true)] TimerInfo timer)
{
try
{
_logger.LogInformation($"Generating data ingestion report:\n{_options.TeamsConfiguration.ToJsonDebug()}");
await _notificationService.SendNotificationAsync(_options.TeamsConfiguration);
}
catch (Exception ex)
{
_logger.LogError(ex.Message);
throw;
}
}
}
问题可能与区分大小写有关,因为...
- 容器名称中的所有字母都必须小写。
- Blob 名称区分大小写。
检查您的函数设置,确保您的连接字符串、容器名称和 blob 名称正确无误,并且没有任何问题。
有关规则的完整概述,请参阅 Naming and Referencing Containers, Blobs, and Metadata。