Giter Site home page Giter Site logo

kedacore / sample-hello-world-azure-functions Goto Github PK

View Code? Open in Web Editor NEW
75.0 75.0 29.0 146 KB

Simple hello world sample of an Azure Function triggering on an Azure Queue powered by KEDA

License: Apache License 2.0

Dockerfile 54.88% JavaScript 45.12%

sample-hello-world-azure-functions's People

Contributors

anirudhgarg avatar jeffhollan avatar kulkarnisonia16 avatar tomkerkhove avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

sample-hello-world-azure-functions's Issues

kedacore container keeps crashing

I was trying the Azure Functions with Azure Storage Queue trigger. Since the Functions wasnt getting triggered when i looked at my pods in "keda" namespace on my AKS cluster i see the below error. I guess this is the reason why it isnt working. Any pointers on solving this ?

NAME READY STATUS RESTARTS AGE
keda-cdc47687c-9rrsj 0/1 CrashLoopBackOff 5 3m42s
osiris-osiris-edge-activator-8656c567c9-nsmth 1/1 Running 0 3m40s
osiris-osiris-edge-endpoints-controller-cd68bcb65-mnfdf 1/1 Running 0 3m40s
osiris-osiris-edge-endpoints-hijacker-86d74b6fd7-qd6z9 1/1 Running 0 3m39s
osiris-osiris-edge-proxy-injector-85f87d89d4-phmks 1/1 Running 0 3m39s
osiris-osiris-edge-zeroscaler-6576cdd5bd-wt8v7 1/1 Running 0 3m39s

Getting Response status code does not indicate success: 404 (Not Found). while using func kubernetes deploy

A clear and concise description of what the bug is.

Expected Behavior

The functions app is deployed in the AKS cluster without any issue, the problem is related to the Azure DevOps task that fails with error Response status code does not indicate success: 404 (Not Found). even thought the function was properly deployed

Actual Behavior

Azure Function on Kubernetes task should work without that error (Response status code does not indicate success: 404 (Not Found).)

Steps to Reproduce the Problem

  1. Deploy any netcore function app through Azure DevOps task called Azure Function on Kubernetes

Specifications

  • **KEDA Version:2.1.0 *
  • **Kubernetes Version:1.22.4

only one pod scheduled on vNode

Followed instruction to run on VirtualNode and uses following trigger with queueLength 1

triggers:
 - type: azure-queue
   metadata:
     name: msg
     type: queueTrigger
     direction: in
     queueName: blobevents
     connection: org1_STORAGE
     queueLength: 1

Sending 4 messages to the queue, still shows one pod processing all messages sequentially and deployment always has desired state 1

 kubectl get deploy
NAME           DESIRED   CURRENT   UP-TO-DATE   AVAILABLE   AGE
trigger-keda   1         1         1            1           13m

It works as expected on regular Nodes, with 4 pods created ...

The binding type(s) 'queueTrigger' are not registered.

I followed this walkthrough - and everything is working locally. When I deploy to my AKS cluster, I get the following errors from the kubectl logs. I have verified that my host.json has the following
{
"version": "2.0",
"extensionBundle": {
"id": "Microsoft.Azure.Functions.ExtensionBundle",
"version": "[1.*, 2.0.0)"
}
}

The container is succesfully deployed to my docker hub registry
Errors: (sorry for funny encoding)

�[40m�[32minfo�[39m�[22m�[49m: Host.Startup[0]
Initializing Host.
�[40m�[32minfo�[39m�[22m�[49m: Host.Startup[0]
Host initialization: ConsecutiveErrors=0, StartupCount=1
�[40m�[32minfo�[39m�[22m�[49m: Microsoft.Azure.WebJobs.Hosting.JobHostService[0]
Starting JobHost
�[40m�[32minfo�[39m�[22m�[49m: Host.Startup[0]
Starting Host (HostId=hellokeda5f69d8dcb6xdfsd-2137340, InstanceId=db9d97ab-65d3-4a20-91b5-d07f125414a1, Version=2.0.12180.0, ProcessId=7, AppDomainId=1, InDebugMode=False, InDiagnosticMode=False, FunctionsExtensionVersion=)
�[40m�[32minfo�[39m�[22m�[49m: Host.Startup[0]
Loading functions metadata
�[40m�[32minfo�[39m�[22m�[49m: Host.Startup[0]
A function whitelist has been specified, excluding all but the following functions: [QueueTrigger]
�[40m�[32minfo�[39m�[22m�[49m: Host.Startup[0]
1 functions loaded
�[40m�[32minfo�[39m�[22m�[49m: Host.Startup[0]
Generating 0 job function(s)
�[40m�[1m�[33mwarn�[39m�[22m�[49m: Host.Startup[0]
No job functions found. Try making your job classes and methods public. If you're using binding extensions (e.g. Azure Storage, ServiceBus, Timers, etc.) make sure you've called the registration method for the extension(s) in your startup code (e.g. builder.AddAzureStorage(), builder.AddServiceBus(), builder.AddTimers(), etc.).
�[40m�[32minfo�[39m�[22m�[49m: Host.Startup[0]
Host initialized (225ms)
�[40m�[32minfo�[39m�[22m�[49m: Host.Startup[0]
Host started (235ms)
�[40m�[32minfo�[39m�[22m�[49m: Host.Startup[0]
Job host started
�[41m�[30mfail�[39m�[22m�[49m: Host.Startup[0]
The following 1 functions are in error:
QueueTrigger: The binding type(s) 'queueTrigger' are not registered. Please ensure the type is correct and the binding extension is installed.

Hosting environment: Production
Content root path: /
Now listening on: http://[::]:80
Application started. Press Ctrl+C to shut down.
�[40m�[32minfo�[39m�[22m�[49m: Host.General[0]
Host lock lease acquired by instance ID '000000000000000000000000A058A27D'.

Failing to deploy function to Kubernetes

When I follow this sample, I run into issues when deploying to Kubernetes. Things run fine on my machine - but fail when deploying to kube. I tried this both on my Windows laptop as on a Linux machine (with all prereqs installed).

The first error I get is that a deployment doesn't exist - if I run the same deployment again the error refers to the namespace already existing.

Some of the logs I get:

nilfranadmin@webserver:~/hello-keda$ sudo func deploy --platform kubernetes --name hello-keda --registry mcwnfreg.azurecr.io --pull-secret "xxx" --namespace hello-keda4
Building Docker image...
Running 'docker build -t mcwnfreg.azurecr.io/hellokeda /home/nilfranadmin/hello-keda'..done
Pushing function image to registry...
Running 'docker push mcwnfreg.azurecr.io/hellokeda'...done
Error running kubectl delete deployment hello-keda-deployment --namespace hello-keda4.
output: Error from server (NotFound): deployments.extensions "hello-keda-deployment" not found 




nilfranadmin@webserver:~/hello-keda$ sudo func deploy --platform kubernetes --name hello-keda --registry mcwnfreg.azurecr.io --pull-secret "xxx" --namespace hello-keda4
Building Docker image...
Running 'docker build -t mcwnfreg.azurecr.io/hellokeda /home/nilfranadmin/hello-keda'..done
Pushing function image to registry...
Running 'docker push mcwnfreg.azurecr.io/hellokeda'..done
Error running kubectl create ns hello-keda4.
output: Error from server (AlreadyExists): namespaces "hello-keda4" already exists

extensionBundle in host.json breaks DI

I have an issue I finally traced to the extensionBundle changes in host.json which are causing DI to not work in a queue-triggered function. I am using IFunctionsHostBuilder and it works correctly if the extensions are omitted.

DI works:

{
    "version": "2.0"
}

DI doesn't work:

{
    "version": "2.0",
    "extensionBundle": {
        "id": "Microsoft.Azure.Functions.ExtensionBundle",
        "version": "[1.*, 2.0.0)"
    }
}

My queue-triggered function still works without the extensionBundle specified and I would like to understand under what scenarios are they needed?

Thanks

Fail to build Image on Step 9a

Environment

Ubuntu 18.04
Docker:

Client: Docker Engine - Community
 Version:           19.03.7
 API version:       1.40
 Go version:        go1.12.17
 Git commit:        7141c199a2
 Built:             Wed Mar  4 01:22:36 2020
 OS/Arch:           linux/amd64
 Experimental:      false

Server: Docker Engine - Community
 Engine:
  Version:          19.03.7
  API version:      1.40 (minimum version 1.12)
  Go version:       go1.12.17
  Git commit:       7141c199a2
  Built:            Wed Mar  4 01:21:08 2020
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.2.13
  GitCommit:        7ad184331fa3e55e52b890ea95e65ba581ae3429
 runc:
  Version:          1.0.0-rc10
  GitCommit:        dc9208a3303feef5b3839f4323d9beb36df0a9dd
 docker-init:
  Version:          0.18.0
  GitCommit:        fec3683

Azure Functions Core Tools: 3.0.2245
func kubernetes deploy --name hello-keda --registry xxxxxxxxxx --dry-run

data:
  FUNCTIONS_WORKER_RUNTIME: bm9kZQ==
  AzureWebJobsStorage: XXXXXXXXXXXXXXXXXX
apiVersion: v1
kind: Secret
metadata:
  name: hello-keda
  namespace: default
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: hello-keda
  namespace: default
  labels:
    app: hello-keda
spec:
  selector:
    matchLabels:
      app: hello-keda
  template:
    metadata:
      labels:
        app: hello-keda
    spec:
      containers:
      - name: hello-keda
        image: paulplavetzki/hello-keda
        env:
        - name: AzureFunctionsJobHost__functions__0
          value: QueueTrigger
        envFrom:
        - secretRef:
            name: hello-keda
---
apiVersion: keda.k8s.io/v1alpha1
kind: ScaledObject
metadata:
  name: hello-keda
  namespace: default
  labels:
    deploymentName: hello-keda
spec:
  scaleTargetRef:
    deploymentName: hello-keda
  triggers:
  - type: azure-queue
    metadata:
      name: myQueueItem
      type: queueTrigger
      direction: in
      queueName: js-queue-items
      connection: AzureWebJobsStorage
---

Error

Running 'docker build -t paulplavetzki/hello-keda /home/pplavetzki/development/hack/hello-keda'.......................done
Error running docker build -t paulplavetzki/hello-keda /home/pplavetzki/development/hack/hello-keda.
output: Sending build context to Docker daemon  11.26kB

Step 1/4 : FROM mcr.microsoft.com/azure-functions/node:3.0
3.0: Pulling from azure-functions/node
8ec398bc0356: Pulling fs layer
fdb3dcd3402e: Pulling fs layer
3f9a385b80e9: Pulling fs layer
e890320b6235: Pulling fs layer
9e15ad3389a8: Pulling fs layer
75fa7c47d1cf: Pulling fs layer
e890320b6235: Waiting
9e15ad3389a8: Waiting
75fa7c47d1cf: Waiting
fdb3dcd3402e: Verifying Checksum
fdb3dcd3402e: Download complete
8ec398bc0356: Verifying Checksum
8ec398bc0356: Download complete
8ec398bc0356: Pull complete
fdb3dcd3402e: Pull complete
3f9a385b80e9: Verifying Checksum
3f9a385b80e9: Download complete
3f9a385b80e9: Pull complete
75fa7c47d1cf: Verifying Checksum
75fa7c47d1cf: Download complete
9e15ad3389a8: Verifying Checksum
9e15ad3389a8: Download complete
e890320b6235: Download complete
e890320b6235: Pull complete
9e15ad3389a8: Pull complete
75fa7c47d1cf: Pull complete
Digest: sha256:59402486e0d3d4a7042470798de37ed036ecda5e71d4a61be6a25d977c1b0278
Status: Downloaded newer image for mcr.microsoft.com/azure-functions/node:3.0
 ---> d69666cc3d2f
Step 2/4 : ENV AzureWebJobsScriptRoot=/home/site/wwwroot     AzureFunctionsJobHost__Logging__Console__IsEnabled=true
 ---> Running in c0f5d9851333
Removing intermediate container c0f5d9851333
 ---> fcd540a71615
Step 3/4 : COPY . /home/site/wwwroot
 ---> ac67f8896a46
Step 4/4 : RUN cd /home/site/wwwroot &&     npm install
 ---> Running in 777ee398c30c
/bin/sh: 1: npm: not found

Expected

I assumed it would build the image, push to registry and then deploy to k8s.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.