Skip to content
This repository has been archived by the owner on Jul 19, 2024. It is now read-only.

WebJobBillingData Functions.ProcessQueueMessage failling #82

Open
yogaanandk opened this issue Jul 23, 2018 · 4 comments
Open

WebJobBillingData Functions.ProcessQueueMessage failling #82

yogaanandk opened this issue Jul 23, 2018 · 4 comments

Comments

@yogaanandk
Copy link

Hi

WebJobBillingData is failing with below error

Microsoft.Azure.WebJobs.Host.FunctionInvocationException: Microsoft.Azure.WebJobs.Host.FunctionInvocationException: Exception while executing function: Functions.ProcessQueueMessage ---> System.NullReferenceException: Object reference not set to an instance of an object.
at WebJobBillingData.Functions.ProcessQueueMessage(BillingRequest billingRequest, TextWriter logWriter)
at lambda_method(Closure , Functions , Object[] )
at Microsoft.Azure.WebJobs.Host.Executors.VoidMethodInvoker1.InvokeAsync(TReflected instance, Object[] arguments) at Microsoft.Azure.WebJobs.Host.Executors.FunctionInvoker1.d__8.MoveNext()

Please assist

@jobalbz
Copy link

jobalbz commented Jul 30, 2018

This is what fixed my deployment after a few days of frustrations. All of a sudden it stopped pulling data and got that exact error. The bug was in the JSON serializer under the RecordDataReader.cs". For some reason, all empty tables being pulled became NULL and the code coverts them to string. That's where it failed. Please see 2 lines of code that i've added to make sure there a no NULL values. I'm not a developer so if you can come up with a more elegant way of fixing this issue, please let me know.

private static string SerializeDictionary(IDictionary dictionary)
{
var textBuilder = new StringBuilder();

	using (var textWriter = new StringWriter(textBuilder)) {
		JsonTextWriter writer = new JsonTextWriter(textWriter);
		writer.WriteStartArray();

		foreach (object key in dictionary.Keys) {
			object value = dictionary[key];
			writer.WriteStartObject();
			writer.WritePropertyName("Name");
			writer.WriteValue(key.ToString());
			writer.WritePropertyName("Value");
			//added by jobalbz
			{
				if (value == null)
					value = "";
			}
			writer.WriteValue(value.ToString());
			writer.WriteEndObject();
		}
		writer.WriteEndArray();
	}

	return textBuilder.ToString();
}

@mustafakasap
Copy link
Contributor

@jobalbz you can make a pull request for this fix and I can commit

@jobalbz
Copy link

jobalbz commented Aug 8, 2018

@mustafakasap we can now pull data with that fix. Thanks

alexchx added a commit to alexchx/AzureUsageAndBillingPortal that referenced this issue Aug 16, 2018
@alexchx
Copy link

alexchx commented Aug 16, 2018

@mustafakasap Committed a fix in PR #85

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants