api-version: 2024-02-02-preview
location: {{ .Env.AZURE_LOCATION }}
identity:
  type: UserAssigned
  userAssignedIdentities:
    ? "{{ .Env.AZURE_CONTAINER_REGISTRY_MANAGED_IDENTITY_ID }}"
    : {}
properties:
  environmentId: {{ .Env.AZURE_CONTAINER_APPS_ENVIRONMENT_ID }}
  configuration:
    activeRevisionsMode: single
    runtime:
      dotnet:
        autoConfigureDataProtection: true
    ingress:
      external: false
      targetPort: {{ targetPortOrDefault 8080 }}
      transport: http
      allowInsecure: true
    registries:
      - server: {{ .Env.AZURE_CONTAINER_REGISTRY_ENDPOINT }}
        identity: {{ .Env.AZURE_CONTAINER_REGISTRY_MANAGED_IDENTITY_ID }}
    secrets:
      - name: cache-password
        value: '{{ securedParameter "cache_password" }}'
      - name: connectionstrings--blobs
        value: '{{ .Env.STORAGE_BLOBENDPOINT }}'
      - name: connectionstrings--cache
        value: cache:6379,password={{ securedParameter "cache_password" }}
      - name: connectionstrings--mongodb
        value: mongodb://admin:{{ uriEncode (securedParameter "mongo_password" )}}@mongo:27017/mongodb?authSource=admin&authMechanism=SCRAM-SHA-256
      - name: connectionstrings--queues
        value: '{{ .Env.STORAGE_QUEUEENDPOINT }}'
      - name: connectionstrings--sqldb
        value: Server=tcp:{{ .Env.SQL_SQLSERVERFQDN }},1433;Encrypt=True;Authentication="Active Directory Default";Database=sqldb
      - name: connectionstrings--tables
        value: '{{ .Env.STORAGE_TABLEENDPOINT }}'
      - name: mongodb-password
        value: '{{ securedParameter "mongo_password" }}'
  template:
    containers:
      - image: {{ .Image }}
        name: apiservice
        env:
          - name: AZURE_CLIENT_ID
            value: {{ .Env.MANAGED_IDENTITY_CLIENT_ID }}
          - name: ASPNETCORE_FORWARDEDHEADERS_ENABLED
            value: "true"
          - name: BLOBS_URI
            value: '{{ .Env.STORAGE_BLOBENDPOINT }}'
          - name: CACHE_HOST
            value: cache
          - name: CACHE_PORT
            value: "6379"
          - name: CACHE_URI
            value: redis://:{{ uriEncode (securedParameter "cache_password" )}}@cache:6379
          - name: HTTP_PORTS
            value: '{{ targetPortOrDefault 0 }}'
          - name: IDP_HTTP
            value: http://idp.{{ .Env.AZURE_CONTAINER_APPS_ENVIRONMENT_DEFAULT_DOMAIN }}
          - name: MONGODB_AUTHENTICATIONDATABASE
            value: admin
          - name: MONGODB_AUTHENTICATIONMECHANISM
            value: SCRAM-SHA-256
          - name: MONGODB_DATABASENAME
            value: mongodb
          - name: MONGODB_HOST
            value: mongo
          - name: MONGODB_PORT
            value: "27017"
          - name: MONGODB_URI
            value: mongodb://admin:{{ uriEncode (securedParameter "mongo_password" )}}@mongo:27017/mongodb?authSource=admin&authMechanism=SCRAM-SHA-256
          - name: MONGODB_USERNAME
            value: admin
          - name: OTEL_DOTNET_EXPERIMENTAL_OTLP_EMIT_EVENT_LOG_ATTRIBUTES
            value: "true"
          - name: OTEL_DOTNET_EXPERIMENTAL_OTLP_EMIT_EXCEPTION_LOG_ATTRIBUTES
            value: "true"
          - name: OTEL_DOTNET_EXPERIMENTAL_OTLP_RETRY
            value: in_memory
          - name: QUEUES_URI
            value: '{{ .Env.STORAGE_QUEUEENDPOINT }}'
          - name: SQLDB_DATABASENAME
            value: sqldb
          - name: SQLDB_HOST
            value: '{{ .Env.SQL_SQLSERVERFQDN }}'
          - name: SQLDB_JDBCCONNECTIONSTRING
            value: jdbc:sqlserver://{{ .Env.SQL_SQLSERVERFQDN }}:1433;database=sqldb;encrypt=true;trustServerCertificate=false
          - name: SQLDB_PORT
            value: "1433"
          - name: SQLDB_URI
            value: mssql://{{ .Env.SQL_SQLSERVERFQDN }}:1433/sqldb
          - name: TABLES_URI
            value: '{{ .Env.STORAGE_TABLEENDPOINT }}'
          - name: services__idp__http__0
            value: http://idp.{{ .Env.AZURE_CONTAINER_APPS_ENVIRONMENT_DEFAULT_DOMAIN }}
          - name: CACHE_PASSWORD
            secretRef: cache-password
          - name: ConnectionStrings__blobs
            secretRef: connectionstrings--blobs
          - name: ConnectionStrings__cache
            secretRef: connectionstrings--cache
          - name: ConnectionStrings__mongodb
            secretRef: connectionstrings--mongodb
          - name: ConnectionStrings__queues
            secretRef: connectionstrings--queues
          - name: ConnectionStrings__sqldb
            secretRef: connectionstrings--sqldb
          - name: ConnectionStrings__tables
            secretRef: connectionstrings--tables
          - name: MONGODB_PASSWORD
            secretRef: mongodb-password
    scale:
      minReplicas: 1
tags:
  azd-service-name: apiservice
  aspire-resource-name: apiservice
