所以我有一个整天都在工作的天蓝色功能。大约二十分钟前,尝试单击Visual Studio中的“运行”按钮时,我开始出现错误。它会成功构建,然后在启动时显示并显示错误,只是指出“路径中的非法字符-Visual Studio”。我已经检查了git日志,没有进行任何更改,所以我真的不确定是怎么回事。
我附上了问题的图片,以尝试说明问题。
我真的尽了我所能想到的一切。这是我已采取的所有步骤的清单。
using Microsoft.Azure.WebJobs;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Zupa.Products.ProductsService.Models.Messages.V1;
namespace Zupa.ProductFileUploadFunction
{
public static class FileUploadProcessor
{
private const string FunctionName = nameof(FileUploadProcessor);
[FunctionName(FunctionName)]
public static void Run(
[BlobTrigger("%IncomingContainerPath%/{blobFileName}", Connection = "AzureWebJobsStorage")]Stream inputBlob,
[ServiceBus("%QueueName%", Connection = "QueueServiceBus")]out string outgoingMessage,
string blobFileName, ILogger log)
{
log.LogInformation($"{FunctionName} Processing blob {Environment.NewLine} Name:{blobFileName + Environment.NewLine} Size: {inputBlob.Length} Bytes");
outgoingMessage = null;
var (parsedOrganisationId, parsedUploadId) = (Guid.Empty, Guid.Empty);
var organisationId = GetPartFromString(blobFileName, "/", 0);
var fileUploadType = GetPartFromString(blobFileName, "/", 1);
var isRecognisedFileUploadType = Enum.GetNames(typeof(FileUploadType)).Select(name => name.ToLowerInvariant()).Contains(fileUploadType.ToLowerInvariant());
var uploadId = GetPartFromString(blobFileName, "/", 2);
var fileName = GetPartFromString(blobFileName, "/", 3);
var propertyValidation = new Dictionary<string, bool>()
{
{
nameof(FileUploadDataEventMessage.OrganisationId),
string.IsNullOrEmpty(organisationId) || !Guid.TryParse(organisationId, out parsedOrganisationId)
},
{
nameof(FileUploadDataEventMessage.FileUploadType),
string.IsNullOrEmpty(fileUploadType) || isRecognisedFileUploadType
},
{
nameof(FileUploadDataEventMessage.UploadId),
string.IsNullOrEmpty(uploadId) || !Guid.TryParse(uploadId, out parsedUploadId)
},
{
nameof(FileUploadDataEventMessage.FileName),
string.IsNullOrEmpty(fileName)
}
};
foreach (KeyValuePair<string, bool> propertyValidationPair in propertyValidation)
LogPropertyInErrorState(log, propertyValidationPair.Value, blobFileName, propertyValidationPair.Key);
var hasInvalidPathParameters = parsedOrganisationId == Guid.Empty || !isRecognisedFileUploadType || parsedUploadId == Guid.Empty || string.IsNullOrEmpty(fileName);
outgoingMessage = !hasInvalidPathParameters ? JsonConvert.SerializeObject(new FileUploadDataEventMessage()
{
OrganisationId = parsedOrganisationId,
UploadId = parsedUploadId,
FileUploadType = Enum.Parse<FileUploadType>(PascalCaseWord(fileUploadType)),
FileName = fileName,
Timestamp = DateTimeOffset.Now
}) : null;
log.LogInformation($"{FunctionName} Processed blob {Environment.NewLine} Name:{blobFileName + Environment.NewLine} Size: {inputBlob.Length} Bytes");
}
private static string GetPartFromString(string inputString, string delimiter, int targetIndex)
{
var inputStringParts = inputString.Split(delimiter);
if (inputStringParts.ElementAtOrDefault(targetIndex) != null)
return inputStringParts[targetIndex];
return null;
}
private static void LogPropertyInErrorState(ILogger log, bool errorValidationCondition, string fileName, string propertyName)
{
var errorMessage = errorValidationCondition ?
$"{FunctionName} Failed to process blob {Environment.NewLine} Name: {fileName + Environment.NewLine} Missing or invalid {propertyName}" : string.Empty;
if (!string.IsNullOrEmpty(errorMessage))
log.LogInformation(errorMessage);
}
private static string PascalCaseWord(string input) =>
input.Substring(0, 1).ToUpperInvariant() + input.Substring(1);
}
}
该功能似乎不是问题,因为团队的其他成员似乎没有遇到相同的问题并且可以成功运行该功能。因此,我认为这是系统问题。
更新: 对于遇到此问题的任何人,我终于找到了解决此问题的方法
非常感谢您在媒体上的Tsuyoshi Ushio,请按照以下步骤解决问题,似乎是当Azure功能工具文件在%appdata%/ local文件夹中处于错误状态时
答案 0 :(得分:4)
对于遇到此问题的任何人,我终于找到了解决此问题的方法
非常感谢您在媒体上的Tsuyoshi Ushio,请按照以下步骤解决问题,似乎是当Azure功能工具文件在%appdata%/ local文件夹中处于错误状态时
答案 1 :(得分:0)
您需要删除以下文件夹:
%localappdata%\AzureFunctionsTools