Coder Social home page Coder Social logo

myazurevision's Introduction

myazurevision

 a asp.net core 6.0 project using azure vision api to detect images tag
 appengine/* deploy to gcp appengine
 k8s/*       depoly to gcp kubernates

appengine

Step 1

install gcloud sdk

Step2

edit app.yaml

runtime: aspnetcore
env: flex
service: app-azure-vision-service

runtime_config:
  operating_system: ubuntu22

# This sample incurs costs to run on the App Engine flexible environment. 
# The settings below are to reduce costs during testing and are not appropriate
# for production use. For more information, see:
# https://cloud.google.com/appengine/docs/flexible/dotnet/configuring-your-app-with-app-yaml
manual_scaling:
  instances: 1
resources:
  cpu: 1
  memory_gb: 0.5
  disk_size_gb: 10

env_variables:
  azure_api_key: 'YOUR_AZURE_API_KEY'
  azure_api_endpoint: 'YOUR_AZURE_ENDPOINT'

step 3

gcloud config set project xxxxx
# deploy service : app-azure-vision-service
gcloud app deploy --version=v1

k8s

Step 1: publish

publish dotnet core project and copy pubish folder to k8s/MyAzureVision/publish

Step 2: Dockerfile

FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS runtime
WORKDIR /app
COPY publish/ ./
EXPOSE 8080/tcp 
ENV ASPNETCORE_URLS http://*:8080
ENTRYPOINT ["dotnet", "MyAzureVision.dll"]

step3. create secret

kubectl create secret generic azuresecret --from-literal=azure_api_key=xxx --from-literal=azure_api_endpoint=https://xxxxx.cognitiveservices.azure.com/

step4. deploy to GKE

#get credentials
gcloud container clusters get-credentials my-cluster --zone us-central1-c --project  my-kubernates-xxxx

#set your prject
gcloud config set project my-kubernates-398208

#build your images
docker build -t michaelfangtw/myazurevision:1.0 .

#push your images to docker hub
docker push michaelfangtw/myazurevision:1.0
kubectl delete deployment myazurevision  

#k8s deploy workloads from docker hub registry 
kubectl create deployment myazurevision  --image=michaelfangtw/myazurevision:1.0

#export workloads to public ip / port
kubectl delete service myazurevision
kubectl expose deployment myazurevision --type=LoadBalancer --port=80 --target-port=8080
kubectl get svc --watch

Step5. modify myazurevision.yaml to mapping secret value to enviorment variables

      containers:
        - env:
            - name: azure_api_key
              valueFrom:
                secretKeyRef:
                  name: azuresecret
                  key: azure_api_key
            - name: azure_api_endpoint
              valueFrom:
                secretKeyRef:
                  name: azuresecret
                  key: azure_api_endpoint
          image: michaelfangtw/myazurevision:1.0

myazurevision's People

Contributors

michaelfangtw avatar

Watchers

 avatar

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.