Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

src folder missing after deploying Azure Function App (v4 Programming model node@20.x) #3612

Open
ihnaqi opened this issue Feb 29, 2024 · 0 comments

Comments

@ihnaqi
Copy link

ihnaqi commented Feb 29, 2024

I zipped, used GitHub workflows, and vs code Azure tool as well. When I deploy my function both zip file and on using workflow get deployed without any error message (no application insight), but he one from vs code get deployed with this verdict No HTTP Triggers found. In each case I can locate application on portal and can see host.josn, package.json, every other file except the src folder gets deployed. How can I solve this problem. I tried reading dozens of issues neither of them seems to solve my problem.

#!/bin/bash

# Define variables
root="./Authentication" # The root directory of the project
utput="function.zip" # The name of the zip file to be created
app="wsdemoazureb2c" # The name of the Azure Function App
rg="wsdemoazureb2c" # The name of the Resource Group
account="wsdemoazureb2c" # The name of the Storage Account

# Check if the Resource Group exists
echo "--> Looking for the Resource Group $rg <--"
az group show --name "$rg" &> /dev/null
if [ $? != 0 ]; then
   echo "The mentioned Resource Group does no exists. Do you want to create one with the name $rg? (y/n)"
   read -r response
   if [ "$response" = "y" ]; then
      echo "Creating the Resource Group..."
      az group create --name "$rg" --location "Central US"
      echo "Resource Group has been created."
   else
      echo "The deployment has been cancelled, please modify your Resource Group name."
      exit 1
   fi
fi
echo "--> Resource group has been located. <--"

# Check if the Function App exists
echo "--> Looking for the Function App $app within the resource $rg<--"
if ! az functionapp show --name "$app" \
   --resource-group "$rg" &> /dev/null; then
   echo "No function app with the specified name exists. Do you want to create one with the name $app? (y/n)"
   read -r response
   if [ "$response" = "y" ]; then
      echo "Creating the Function App..."
      az functionapp create \
         --consumption-plan-location "centralus" \
         --name "$app" \
         --os-type Linux \
         --resource-group "$rg" \
         --storage-account "$account" \
         --runtime node \
         --functions-version 4
      echo "Function App has been created."
   fi   
else
   echo "Azure function has been located."
fi

# Navigate to the project root
cd "$root" || exit
 
echo "--> Looking for pre existing zip files with the same name. <--"
# Check if the zip file exists and delete it
if [ -f "$output" ]; then 
   echo "A zip file with the same name exists. Do you want to delete it? (y/n)"
   read -r response
   if [ "$response" = "y" ]; then
      rm "$output"
      echo "The existing zip file has been deleted."
   else
      echo "The deployment has been cancelled, please modify your zip name."
      exit 1
   fi
fi
echo "--> Zip has been created. or it already exited. <--"

# Create a zip file of the necessary contents, excluding unwanted files and directories
echo "Zipping the project files..."
7z a -tzip "$output" .\
   -xr!node_modules/* \
   -xr!.vscode \
   -xr!~* \
   -xr!.funcignore \
   -xr!host-settings.json \
   -xr!*.zip \
   -xr!.env \
   -xr!README.md 
echo "Zip file has been sucessfully created."

# Deploy the zip file to the Azure Function App
echo "Deploying the zip file to the Azrue Function App..."
az functionapp deployment source config-zip \
   --resource-group "$rg" \
   --name "$app" \
   --src "$output"
echo "Deployment has been completed."

The application insight is empty, by that I can assume that there doesn't occurred any error while deploying the function app. Here is screenshot from app files of the function app section.
image

And here is my folder structure
image

I can also see all the files inside the zip file.

Tasks

No tasks being tracked yet.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant