簡體   English   中英

我正在嘗試使用 Bicep 模板將帶有服務總線部署的邏輯應用程序部署到 azure 應用程序

[英]I am trying to deploy a Logic-App with a Service-Bus Deploy to azure app using Bicep template

我正在嘗試部署二頭肌模板以使用 VS Code 創建邏輯應用程序和服務總線。 但是當我嘗試將 Bicep 部署到 azure 門戶時,我遇到了錯誤的請求錯誤

在此處輸入圖像描述

這是我的二頭肌樣子

param prefix string
param location string = resourceGroup().location
param sendGridApiKey string

resource serviceBus 'Microsoft.ServiceBus/namespaces@2021-11-01' existing = {
  name: '${prefix}sb'
}

resource serviceBusConnection 'Microsoft.Web/connections@2016-06-01' = {
  name: '${prefix}sbconn'
  location: location
  properties: {
    displayName: '${prefix}sb'
    api: {
      id: '${subscription().id}/providers/Microsoft.Web/locations/${location}/managedApis/servicebus'
    }
    parameterValueSet: {
      name: 'managedIdentityAuth'
      values: {
        namespaceEndpoint: {
          value: 'sb://${serviceBus.name}.servicebus.windows.net'
        }
      }
    }
  }
}

resource sendGridConnection 'Microsoft.Web/connections@2016-06-01' = {
  name: '${prefix}sndgrdconn'
  location: location
  properties: {
    displayName: '${prefix}sndgrdconn'
    api: {
      id: '${subscription().id}/providers/Microsoft.Web/locations/${location}/managedApis/sendgrid'
    }
    parameterValues: {
      apiKey: sendGridApiKey
    }
  }
}

resource logicAppEmailSend 'Microsoft.Logic/workflows@2019-05-01' = {
  name: '${prefix}logic-EmailSend'
  location: location
  identity: {
    type: 'SystemAssigned'
  }
  properties: {
    state: 'Enabled'
    definition: {
      '$schema': 'https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#'
      contentVersion: '1.0.0.0'
      parameters: {
        '$connections': {
          defaultValue: {}
          type: 'Object'
        }
      }
    }
  }
}
    
      


     

我已經嘗試了很多但沒有發現錯誤

提前致謝。

  • 我已經修改了給定代碼中的一些代碼,因此它可以正常工作,並且我已經使用 VS Code 將二頭肌文件部署到 Azure

{subscription().id}/providers/Microsoft.Web/locations/{location}/servicebus

  • 我已將上述路徑更改為

{subscription().id}/providers/Microsoft.Web/locations/{location}/managedApis/servicebus

感謝@mattruma的二頭肌模板

param prefix string
param location string = resourceGroup().location
param sendGridApiKey string

resource serviceBus 'Microsoft.ServiceBus/namespaces@2021-11-01' existing = {
  name: '${prefix}sb'
}

resource serviceBusConnection 'Microsoft.Web/connections@2016-06-01' = {
  name: '${prefix}sbconn'
  location: location
  properties: {
displayName: '${prefix}sb'
    api:
    {
    id: '${subscription().id}/providers/Microsoft.Web/locations/${location}/managedApis/servicebus'
    }
parameterValueSet:
    {
    name: 'managedIdentityAuth'
      values:
        {
        namespaceEndpoint:
            {
            value: 'sb://${serviceBus.name}.servicebus.windows.net'
        }
        }
    }
}
}

resource logicAppEmailSend 'Microsoft.Logic/workflows@2019-05-01' = {
  name: '${prefix}logic-EmailSend'
  location: location
  identity: {
type: 'SystemAssigned'
  }
properties:
{
state: 'Enabled'
    definition:
    {
        '$schema': 'https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#'
      contentVersion: '1.0.0.0'
      parameters:
        {
            '$connections': {
            defaultValue: { }
            type: 'Object'
            }
        }
    triggers:
        {
            'When_a_message_is_received_in_a_queue_(auto-complete)': {
            recurrence:
                {
                frequency: 'Minute'
              interval: 3
            }
            evaluatedRecurrence:
                {
                frequency: 'Minute'
              interval: 3
            }
            type: 'ApiConnection'
              inputs:
                {
                host:
                    {
                    connection:
                        {
                        name: '@parameters(\'$connections\')[\'servicebus\'][\'connectionId\']'
                    }
                    }
                method: 'get'
            path: '/@{encodeURIComponent(encodeURIComponent(\'emailsend\'))}/messages/head'
            queries:
                    {
                    queueType: 'Main'
            }
                }
            }
        }
    actions:
        {
            'Dead-letter_the_message_in_a_queue': {
            runAfter:
                {
                Send_email: [
                  'Failed'
                'TimedOut'
              ]
          }
            type: 'ApiConnection'
              inputs:
                {
                host:
                    {
                    connection:
                        {
                        name: '@parameters(\'$connections\')[\'servicebus\'][\'connectionId\']'
                    }
                    }
                method: 'post'
            path: '/@{encodeURIComponent(encodeURIComponent(\'emailsend\'))}/messages/deadletter'
            queries:
                    {
                    deadLetterErrorDescription: ''
              deadLetterReason: ''
              lockToken: '@triggerBody()?[\'LockToken\']'
              sessionId: '@triggerBody()?[\'SessionId\']'
            }
                }
            }
        Parse_message:
            {
            runAfter: { }
            type: 'ParseJson'
          inputs:
                {
                content: '@base64ToString(triggerBody()?[\'ContentData\'])'
            schema:
                    {
                    properties:
                        {
                        body:
                            {
                            type: 'string'
                        }
                        subject:
                            {
                            type: 'string'
                        }
                        to:
                            {
                            type: 'string'
                        }
                        }
                    type: 'object'
            }
                }
            }
        Send_email:
            {
            runAfter:
                {
                Parse_message: [
                  'Succeeded'
              ]
          }
            type: 'ApiConnection'
          inputs:
                {
                body:
                    {
                    from: 'someone@somewhere.com'
                  fromname: 'Someone'
                  ishtml: true
                  subject: '@body(\'Parse_message\')?[\'subject\']'
                  text: '<p>@{body(\'Parse_message\')?[\'body\']}</p>'
                  to: '@body(\'Parse_message\')?[\'to\']'
                }
                host:
                    {
                    connection:
                        {
                        name: '@parameters(\'$connections\')[\'sendgrid\'][\'connectionId\']'
                    }
                    }
                method: 'post'
            path: '/v4/mail/send'
          }
            }
        }
    outputs: { }
    }
parameters:
    {
        '$connections': {
        value:
            {
            servicebus:
                {
                connectionId: serviceBusConnection.id
                connectionName: serviceBusConnection.name
                connectionProperties: {
                    authentication:
                        {
                        type: 'ManagedServiceIdentity'
                    }
                    }
                id: '${subscription().id}/providers/Microsoft.Web/locations/${location}/managedApis/servicebus'
            }
            }
        }
    }
}
}
  • 成功部署到azure門戶后

在此處輸入圖像描述

  • 單擊轉到資源組,它將重定向到下面的頁面

在此處輸入圖像描述

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM