Azure / azure-libraries-for-net

Azure libraries for .Net
MIT License
380 stars 192 forks source link

AppServices.FunctionApps.GetByResourceGroup() gives null exception #222

Open sandervandevelde opened 6 years ago

sandervandevelde commented 6 years ago

When I run var test = _azure.AppServices.FunctionApps.GetByResourceGroup("group without functionapp", functionappname); in a resourse group without an existing functionapp, I get an "Object reference not set to an instance of an object" error.

When the resource group contains one (or more) Function apps, a correct list is shown (tested with one function app).

Stacktrace:

at Microsoft.Azure.Management.AppService.Fluent.FunctionAppsImpl.d5.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.Azure.Management.AppService.Fluent.FunctionAppsImpl.d4.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.Azure.Management.ResourceManager.Fluent.Core.Extensions.Synchronize[TResult](Func1 function) at Microsoft.Azure.Management.ResourceManager.Fluent.Core.GroupableResources5.GetByResourceGroup(String groupName, String name) at AzureResourcesDeployment.ResourcegroupHelper.Run() in C:\Users\sander.vandevelde\source\repos\ConsoleApp3\AzureResourcesDEployment\ResourcegroupHelper.cs:line 137 at AzureResourcesDeployment.Program.Main(String[] args) in C:\Users\sander.vandevelde\source\repos\ConsoleApp3\AzureResourcesDEployment\Program.cs:line 32

at Microsoft.Azure.Management.AppService.Fluent.FunctionAppsImpl.d5.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.Azure.Management.AppService.Fluent.FunctionAppsImpl.d4.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.Azure.Management.ResourceManager.Fluent.Core.Extensions.Synchronize[TResult](Func1 function) at Microsoft.Azure.Management.ResourceManager.Fluent.Core.GroupableResources5.GetByResourceGroup(String groupName, String name) at AzureResourcesDeployment.ResourcegroupHelper.Run() in C:...\AzureResourcesDEployment\ResourcegroupHelper.cs:line 137 at AzureResourcesDeployment.Program.Main(String[] args) in C:...\AzureResourcesDEployment\Program.cs:line 32

gorillapower commented 6 years ago

I found that a workaround for me was to use the webapp endpoint. I wanted see if the a function existed, using something like var test = _azure.WebApps.GetByResourceGroup("group without functionapp", functionappname); worked as Exists() function.