Azure / azure-powershell

Microsoft Azure PowerShell
Other
4.26k stars 3.86k forks source link

New-AzFunctionApp returns uninformative error when Linux Azure functions are created in resourceGroups with Windows-based functions #13315

Open jmagosta opened 4 years ago

jmagosta commented 4 years ago

Known problem

As the Azure function documentation explains You can't host Linux and Windows apps in the same resource group.

New-AzFunctionApp returns an uninformative error message and value when this occurs.

Steps to reproduce

Run this command

New-AzFunctionApp -ResourceGroupName NfvGroupTest -Name MLtmp -Runtime python -RuntimeVersion 3.8 -FunctionsVersion 3 -OSType Linux

when there are existing function apps on Windows on "NfvGroupTest"

Error output

Az.Functions.internal\New-AzFunctionApp : The server responded with a Server Error, Status: InternalServerError
At C:\Users\joagosta\Documents\WindowsPowerShell\Modules\Az.Functions\1.0.2\custom\New-AzFunctionApp.ps1:506 char:17
+ ...             Az.Functions.internal\New-AzFunctionApp @PSBoundParameter ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: ({ ResourceGroup...20190801.Site }:<>f__AnonymousType0`4) [New-AzFunctionApp_Create], RestException`1
    + FullyQualifiedErrorId : InternalServerError,Microsoft.Azure.PowerShell.Cmdlets.Functions.Cmdlets.NewAzFunctionApp_Create
VERBOSE: Your Linux function app 'bvtMLtmp', that uses a consumption plan has been successfully created but is not active until content is published using Azure Portal or the Functions Core Tools.

> $?
$true

This is both incorrect and misleading. It implies that the function app has been successfully created. Note that the same action in the Portal generates an intelligible response:

{
   "code":"InvalidTemplateDeployment",
   "message":"The template deployment 'Microsoft.Web-FunctionApp-Portal-d42b6bbc-a482' is not valid according to the validation procedure. The tracking id is '34fa672e-ad3f-4dca-91ac-89f79c2cb225'. See inner errors for details.",
   "details":[
      {
         "code":"ValidationForResourceFailed",
         "message":"Validation failed for a resource. Check 'Error.Details[0]' for more information.",
         "details":[
            {
               "code":"LinuxWorkersNotAllowedInResourceGroup",
               "message":"Linux workers are not available in resource group NfvTest. Use this link to learn more https://go.microsoft.com/fwlink/?linkid=831180"
            }
         ]
      }

Module versions

Script     1.0.2      Az.Functions                        {Get-AzFunctionApp, Get-AzFunctionAppAvailableLocation, Get-AzFunctionAppPlan, Get-AzFunctionAppSetting...}
ghost commented 4 years ago

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @ahmedelnably, @fabiocav.

dingmeng-xue commented 4 years ago

Functions team, please help to check this question.

Francisco-Gamino commented 4 years ago

Hi @jmagosta -- Thank you for reporting this issue. We will look into this.

cc: @stefanushinardi @anirudhgarg