Share via

Azure Function Linux Python 3.9 problem

Krzysztof Świdrak 166 Reputation points
2022-08-25T16:02:34.733+00:00

Good day, I would like to implement the bicep azure function based on Python 3.9 linux - while trying this:

resource hostingPlan 'Microsoft.Web/serverfarms@2021-03-01' = {  
  name: 'hpname'  
  location: location  
  kind: 'linux'  
  sku: {  
    name: 'S1'  
    tier: 'Consumption'  
  }  
  properties: {}  
}  


resource functionApp 'Microsoft.Web/sites@2022-03-01' = {  
      name: 'faname'  
      location: location  
      kind: 'functionapp,linux'  
      identity: {  
        type: 'SystemAssigned'  
      }  
      properties: {  
        serverFarmId: hostingPlan.id  
        siteConfig: {  
          linuxFxVersion: 'PYTHON|3.9'  
          appSettings: [  
            {  
              name: 'AzureWebJobsStorage'  
              value: 'DefaultEndpointsProtocol=https;AccountName=${storageAccountName};EndpointSuffix=${environment().suffixes.storage};AccountKey=${storageAccount.listKeys().keys[0].value}'  
            }  
            {  
              name: 'WEBSITE_CONTENTAZUREFILECONNECTIONSTRING'  
              value: 'DefaultEndpointsProtocol=https;AccountName=${storageAccountName};EndpointSuffix=${environment().suffixes.storage};AccountKey=${storageAccount.listKeys().keys[0].value}'  
            }  
            {  
              name: 'WEBSITE_CONTENTSHARE'  
              value: toLower(functionAppName)  
            }  
            {  
              name: 'FUNCTIONS_EXTENSION_VERSION'  
              value: '~4'  
            }  
            {  
              name: 'APPINSIGHTS_INSTRUMENTATIONKEY'  
              value: applicationInsights.properties.InstrumentationKey  
            }  
            {  
              name: 'FUNCTIONS_WORKER_RUNTIME'  
              value: 'python'  
            }  

          ]  
          ftpsState: 'Disabled'  
          minTlsVersion: '1.2'  
        }  
        httpsOnly: true  
      }  
    }  

I am still receiving:

"message": "{\r\n \"Code\": \"BadRequest\",\r\n \"Message\": \"The parameter LinuxFxVersion has an invalid value.\",\r\n \"Target\": null,\r\n \"Details\": [\r\n {\r\n
\"Message\": \"The parameter LinuxFxVersion has an invalid value.\"\r\n },\r\n {\r\n \"Code\": \"BadRequest\"\r\n },\r\n {\r\n \"ErrorEntity\": {\r\n
\"ExtendedCode\": \"01007\",\r\n \"MessageTemplate\": \"The parameter {0} has an invalid value.\",\r\n \"Parameters\": [\r\n \"LinuxFxVersion\"\r\n ],\r\n
\"Code\": \"BadRequest\",\r\n \"Message\": \"The parameter LinuxFxVersion has an invalid value.\"\r\n }\r\n }\r\n ],\r\n \"Innererror\": null\r\n}

Could someone tell me - what is wrong with this, also that would be great if such fields could intelligently show, what can be set - 'PYTHON|3.9' etc.

Azure Functions
Azure Functions

An Azure service that provides an event-driven serverless compute platform.


Answer accepted by question author
  1. VenkateshDodda-MSFT 25,251 Reputation points Microsoft Employee Moderator
    2022-08-26T14:30:15.317+00:00

    anonymous user Thank you for reaching out to Microsoft Q&A. Apologize for my previous comment about LinuxfxVerison we have tested the below bicep template and it is working fine. You can use the below Bicep template to deploy consumption plan function app which is running with 'Python|3.9'

    @description('The name of the function app that you wish to create.')  
    param appName string = '<functionAppName>'  
    param storageAccountType string = 'Standard_LRS'  
      
    @description('Location for all resources.')  
    param location string = 'west us'  
      
    @description('Location for Application Insights')  
    param appInsightsLocation string = location  
      
    var hostingPlanName = appName  
    var applicationInsightsName = appName  
    var storageAccountName = '<strgaccountName>'  
      
    resource storageAccount 'Microsoft.Storage/storageAccounts@2021-08-01' = {  
      name: storageAccountName  
      location: location  
      sku: {  
        name: storageAccountType  
      }  
      kind: 'StorageV2'  
    }  
      
    resource hostingPlan 'Microsoft.Web/serverfarms@2021-03-01' = {  
       name: hostingPlanName  
       location: location  
      kind:'linux'  
       sku: {  
        name: 'Y1'  
        tier: 'Dynamic'  
        size: 'Y1'  
        family: 'Y'  
       }  
       properties: {  
        reserved: true  
       }  
     }    
       
     resource applicationInsights 'Microsoft.Insights/components@2020-02-02' = {  
      name: applicationInsightsName  
      location: appInsightsLocation  
      kind: 'web'  
      properties: {  
        Application_Type: 'web'  
        Request_Source: 'rest'  
      }  
    }  
      
         
     resource functionApp 'Microsoft.Web/sites@2022-03-01' = {  
           name: appName  
           location: location  
           kind: 'functionapp,linux'  
           identity: {  
             type: 'SystemAssigned'  
           }  
           properties: {  
             serverFarmId: hostingPlan.id  
             reserved:true  
             siteConfig: {  
               appSettings: [  
                {  
                  name: 'APPLICATIONINSIGHTS_CONNECTION_STRING'  
                  value: applicationInsights.properties.ConnectionString  
                }    
                 {  
                   name: 'AzureWebJobsStorage'  
                   value: 'DefaultEndpointsProtocol=https;AccountName=${storageAccount.name};AccountKey=${listkeys(storageAccount.id,storageAccount.apiVersion).keys[0].value};EndpointSuffix=${environment().suffixes.storage};'  
                 }  
                 {  
                   name: 'FUNCTIONS_EXTENSION_VERSION'  
                   value: '~4'  
                 }  
                 {  
                  name: 'FUNCTIONS_WORKER_RUNTIME'  
                  value: 'python'  
                }   
               ]  
             linuxFxVersion:'Python|3.9'  
             ftpsState:'Disabled'  
             minTlsVersion:'1.2'  
             }  
             httpsOnly:true  
           }  
         }  
    

    You can refer to this documentation, about which properties under site config need to be used based on the function app plan type (whether consumption plan, elastic premium plan or App service plan) this documentation talks about the ARM template but this implies the same for the Bicep template as well.

    have an app that is created on VSCode, can I somehow deploy it automatically with Bicep or from GitHub?
    You can follow these documentation steps on how to deploy Bicep template through visual studio code.

    Incase if you face any issue while deploying the above template, please let me know so that I can connect with you to assist you further.

    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.