无法完全终止/清除 Azure Durable Function
Unable to terminate/ purge Azure Durable Function entirely
我已经从我的代码中删除了一些函数。但我似乎一直收到这些功能尽管已删除但仍不可用。
[2021-07-19T02:47:28.400Z] Activity function 'MainActTemp' does not exist.. InstanceId: . Function: MainActTemp. HubName: TestHubName. AppName: . SlotName: . ExtensionVersion: 2.5.0. SequenceNumber: 2.
[2021-07-19T02:47:29.387Z] The function 'MainSubtemp' doesn't exist, is disabled, or is not an orchestrator function. Additional info: The following are the known orchestrator functions: .. InstanceId: f3c412cd19e54926a9343f618d6f3083:0. Function: MainSubtemp. HubName: TestHubName. AppName: . SlotName: . ExtensionVersion: 2.5.0. SequenceNumber: 3.
我有以下代码来终止和清除我拥有的所有实例 运行 结果为 0 但我仍然收到上述消息,指出这些函数不存在。
public static async Task<int> TerminateInstances(
[HttpTrigger(AuthorizationLevel.Anonymous, "get", "post")] HttpRequestMessage req,
[DurableClient]IDurableOrchestrationClient starter)
{
// Query for all running instances
OrchestrationStatusQueryResult result = await starter.GetStatusAsync(
new OrchestrationStatusQueryCondition
{
RuntimeStatus = new[]
{
OrchestrationRuntimeStatus.Pending,
OrchestrationRuntimeStatus.Running,
}
},
CancellationToken.None);
// Make a hash set to track all instances we got back
var running = new HashSet<string>(result.DurableOrchestrationState.Select(s => s.InstanceId));
int instanceCount = running.Count;
// Send terminate commands to all instances in parallel
var terminateTasks = new List<Task>();
foreach (string instanceId in running)
{
terminateTasks.Add(starter.TerminateAsync(instanceId, "None"));
}
await Task.WhenAll(terminateTasks);
// Wait for the orchestrations to actually terminate
while (true)
{
// Query all "running" instances in parallel
DurableOrchestrationStatus[] results = await Task.WhenAll(
running.Select(id => starter.GetStatusAsync(id)));
foreach (DurableOrchestrationStatus status in results)
{
// Remove any terminated or completed instances from the hashset
if (status != null &&
status.RuntimeStatus != OrchestrationRuntimeStatus.Pending &&
status.RuntimeStatus != OrchestrationRuntimeStatus.Running)
{
running.Remove(status.InstanceId);
}
}
// We are done once the HashSet has no more items in it
if (running.Count == 0)
{
break;
}
// Still waiting for some instances to complete
await Task.Delay(TimeSpan.FromSeconds(1));
}
return instanceCount;
}
我还查看了我的存储帐户的 table 和队列,它们是空的。我该如何清理?谢谢!
解决方案更新
PurgeInstanceHistoryAsync
或上述清除功能似乎只能删除 <DurableTaskHubName>History
和 <DurableTaskHubName>Instances
table。但是队列和 blob 容器并未完全清除,因此任何未正常终止的函数实例都会导致上述问题。
解决方法是通过以下答案使用单独的 DurableTaskHub 名称和 运行 一次以确保所需的行为,您可以清理 Azure 存储中所有与 testhubname 相关的资源。
您好,您可以通过
更改您的 Azure Durable Function Hub 的名称
已更新
host.json 元数据文件包含与绑定到 Azure Function App 中每个函数相关的持久存储资源的逻辑容器。
版本 2 命名
{
"version": "2.0",
"extensions": {
"durableTask": {
"HubName": "TaskHubV1"
}
}
}
更改后如果正常工作,您需要找出您的存储位置并可以进行手动清理。
我已经从我的代码中删除了一些函数。但我似乎一直收到这些功能尽管已删除但仍不可用。
[2021-07-19T02:47:28.400Z] Activity function 'MainActTemp' does not exist.. InstanceId: . Function: MainActTemp. HubName: TestHubName. AppName: . SlotName: . ExtensionVersion: 2.5.0. SequenceNumber: 2.
[2021-07-19T02:47:29.387Z] The function 'MainSubtemp' doesn't exist, is disabled, or is not an orchestrator function. Additional info: The following are the known orchestrator functions: .. InstanceId: f3c412cd19e54926a9343f618d6f3083:0. Function: MainSubtemp. HubName: TestHubName. AppName: . SlotName: . ExtensionVersion: 2.5.0. SequenceNumber: 3.
我有以下代码来终止和清除我拥有的所有实例 运行 结果为 0 但我仍然收到上述消息,指出这些函数不存在。
public static async Task<int> TerminateInstances(
[HttpTrigger(AuthorizationLevel.Anonymous, "get", "post")] HttpRequestMessage req,
[DurableClient]IDurableOrchestrationClient starter)
{
// Query for all running instances
OrchestrationStatusQueryResult result = await starter.GetStatusAsync(
new OrchestrationStatusQueryCondition
{
RuntimeStatus = new[]
{
OrchestrationRuntimeStatus.Pending,
OrchestrationRuntimeStatus.Running,
}
},
CancellationToken.None);
// Make a hash set to track all instances we got back
var running = new HashSet<string>(result.DurableOrchestrationState.Select(s => s.InstanceId));
int instanceCount = running.Count;
// Send terminate commands to all instances in parallel
var terminateTasks = new List<Task>();
foreach (string instanceId in running)
{
terminateTasks.Add(starter.TerminateAsync(instanceId, "None"));
}
await Task.WhenAll(terminateTasks);
// Wait for the orchestrations to actually terminate
while (true)
{
// Query all "running" instances in parallel
DurableOrchestrationStatus[] results = await Task.WhenAll(
running.Select(id => starter.GetStatusAsync(id)));
foreach (DurableOrchestrationStatus status in results)
{
// Remove any terminated or completed instances from the hashset
if (status != null &&
status.RuntimeStatus != OrchestrationRuntimeStatus.Pending &&
status.RuntimeStatus != OrchestrationRuntimeStatus.Running)
{
running.Remove(status.InstanceId);
}
}
// We are done once the HashSet has no more items in it
if (running.Count == 0)
{
break;
}
// Still waiting for some instances to complete
await Task.Delay(TimeSpan.FromSeconds(1));
}
return instanceCount;
}
我还查看了我的存储帐户的 table 和队列,它们是空的。我该如何清理?谢谢!
解决方案更新
PurgeInstanceHistoryAsync
或上述清除功能似乎只能删除 <DurableTaskHubName>History
和 <DurableTaskHubName>Instances
table。但是队列和 blob 容器并未完全清除,因此任何未正常终止的函数实例都会导致上述问题。
解决方法是通过以下答案使用单独的 DurableTaskHub 名称和 运行 一次以确保所需的行为,您可以清理 Azure 存储中所有与 testhubname 相关的资源。
您好,您可以通过
更改您的 Azure Durable Function Hub 的名称已更新 host.json 元数据文件包含与绑定到 Azure Function App 中每个函数相关的持久存储资源的逻辑容器。
版本 2 命名
{
"version": "2.0",
"extensions": {
"durableTask": {
"HubName": "TaskHubV1"
}
}
}
更改后如果正常工作,您需要找出您的存储位置并可以进行手动清理。