79498508

Date: 2025-03-10 15:49:57
Score: 1
Natty:
Report link

The **"Internal server error"** might be occurring due to the below reasons:

Firstly, make sure that a service endpoint delegation is properly configured between the Function App and the virtual network subnet before integrating them.

Add below service endpoints block under virtual network configuration. If you are using an existing vnet from the portal, you can add it directly over there.

```bash
serviceEndpoints: [
{
service: 'Microsoft.Storage'
locations: [ location ]
}
{
service: 'Microsoft.Web'
}
]
```
Refer [SO](https://stackoverflow.com/a/79290455/19785512) worked by me for the relevant issue.

Also, check the available regions for deploying a flex consumption plan function app and deploy it those regions accordingly.

`az functionapp list-flexconsumption-locations`

![enter image description here](https://i.imgur.com/aXhGFe5.png)

*Modified Bicep code:*

```bash
param location string = 'eastus'
param functionPlanName string = 'asp-japroduct'
param functionAppName string = 'jahappprod'
param functionAppRuntime string = 'dotnet-isolated'
param functionAppRuntimeVersion string = '8.0'
param storageAccountName string = 'mystorejahst'
param logAnalyticsName string = 'worksjah'
param applicationInsightsName string = 'virtualinshg'
param maximumInstanceCount int = 100
param instanceMemoryMB int = 2048
param resourceNameNsgBusiness string = 'nsg-business-enb'
param vnetResourceName string = 'vnetlkenvironment'
param vnetAddressPrefix string = '10.0.0.0/16'
param subnetPrefixBusiness string = '10.0.1.0/24'
param resourceNameSubnetBusiness string = 'subnet--business'
var resourceToken = toLower(uniqueString(subscription().id, resourceGroup().name, location))
var deploymentStorageContainerName = 'app-package-${take(functionAppName, 32)}-${take(resourceToken, 7)}'
var storageRoleDefinitionId = 'b7e6dc6d-f1e8-4753-8033-0f276bb0955b'
resource nsgBusiness 'Microsoft.Network/networkSecurityGroups@2024-01-01' = {
name: resourceNameNsgBusiness
location: location
}
resource vnet 'Microsoft.Network/virtualNetworks@2024-01-01' = {
name: vnetResourceName
location: location
properties: {
addressSpace: {
addressPrefixes: [
vnetAddressPrefix
]
}
enableDdosProtection: false
enableVmProtection: false
}
}
resource subnet 'Microsoft.Network/virtualNetworks/subnets@2024-03-01' = {
parent: vnet
name: resourceNameSubnetBusiness
properties: {
addressPrefix: subnetPrefixBusiness
networkSecurityGroup: {
id: nsgBusiness.id
}
privateEndpointNetworkPolicies: 'Enabled'
privateLinkServiceNetworkPolicies: 'Enabled'
serviceEndpoints: [
{
service: 'Microsoft.Storage'
locations: [ location ]
}
{
service: 'Microsoft.Web'
}
]
}
}

resource logAnalytics 'microsoft.operationalinsights/workspaces@2021-06-01' = {
name: logAnalyticsName
location: location
properties: {
retentionInDays: 30
features: {
searchVersion: 1
}
sku: {
name: 'PerGB2018'
}
}
}

resource applicationInsights 'Microsoft.Insights/components@2020-02-02' = {
name: applicationInsightsName
location: location
kind: 'web'
properties: {
Application_Type: 'web'
WorkspaceResourceId: logAnalytics.id
}
}

resource storageAccount 'Microsoft.Storage/storageAccounts@2023-01-01' = {
name: storageAccountName
location: location
sku: {
name: 'Standard_LRS'
}
kind: 'StorageV2'
properties: {
accessTier: 'Hot'
allowSharedKeyAccess: false
publicNetworkAccess: 'Enabled'
}
}

resource storageAccountName_default 'Microsoft.Storage/storageAccounts/blobServices@2023-01-01' = {
parent: storageAccount
name: 'default'
}

resource storageAccountName_default_deploymentStorageContainer 'Microsoft.Storage/storageAccounts/blobServices/containers@2023-01-01' = {
parent: storageAccountName_default
name: deploymentStorageContainerName
properties: {
publicAccess: 'None'
}
}

resource functionPlan 'Microsoft.Web/serverfarms@2023-12-01' = {
name: functionPlanName
location: location
kind: 'functionapp'
sku: {
tier: 'FlexConsumption'
name: 'FC1'
}
properties: {
reserved: true
}
}

resource functionApp 'Microsoft.Web/sites@2023-12-01' = {
name: functionAppName
location: location
kind: 'functionapp,linux'
identity: {
type: 'SystemAssigned'
}
properties: {
serverFarmId: functionPlan.id
functionAppConfig: {
deployment: {
storage: {
type: 'blobContainer'
value: 'concat(storageAccount.properties.primaryEndpoints.blob, deploymentStorageContainerName)'
authentication: {
type: 'SystemAssignedIdentity'
}
}
}
scaleAndConcurrency: {
maximumInstanceCount: maximumInstanceCount
instanceMemoryMB: instanceMemoryMB
}
runtime: {
name: functionAppRuntime
version: functionAppRuntimeVersion
}
}
siteConfig: {
appSettings: [
{
name: 'AzureWebJobsStorage__accountName'
value: storageAccountName
}
{
name: 'APPLICATIONINSIGHTS_CONNECTION_STRING'
value: applicationInsights.id
}
]
}
}
}

resource Microsoft_Storage_storageAccounts_storageAccountName_storageRoleDefinitionId 'Microsoft.Authorization/roleAssignments@2020-04-01-preview' = {
scope: storageAccount
name: guid(storageAccount.id, storageRoleDefinitionId)
properties: {
roleDefinitionId: resourceId('Microsoft.Authorization/roleDefinitions', storageRoleDefinitionId)
principalId: functionApp.identity.principalId
}
}
param deployTime string = utcNow('u')

var serviceSasToken = storageAccount.listServiceSas(
storageAccount.apiVersion, {
signedResource: 'b'
signedPermission: 'rl'
canonicalizedResource: string('/blob/${storageAccountName}/artifacts')
signedExpiry: dateTimeAdd(deployTime, 'PT1H')
}
).serviceSasToken

var artifactUrl = 'https://${storageAccountName}.blob.${environment().suffixes.storage}/artifacts/${deploymentStorageContainerName}?${serviceSasToken}'

resource functionOneDeploy 'Microsoft.Web/sites/extensions@2024-04-01' = {
parent: functionApp
name: 'onedeploy'
properties: {
packageUri: artifactUrl
remoteBuild: false
}
}
```
*Deployment succeeded:*

![enter image description here](https://i.imgur.com/LHrbgq9.png)

![enter image description here](https://i.imgur.com/xNp1xqX.png)

Reasons:
  • Blacklisted phrase (1): stackoverflow
  • Blacklisted phrase (1): enter image description here
  • Long answer (-1):
  • No code block (0.5):
  • Contains question mark (0.5):
  • High reputation (-1):
Posted by: Jahnavi