使用Azure Bicep订阅Azure EventGrid的Webhook Url失败

使用Azure Bicep订阅Azure EventGrid的Webhook Url失败,azure,azure-resource-manager,azure-blob-storage,azure-eventgrid,azure-bicep,Azure,Azure Resource Manager,Azure Blob Storage,Azure Eventgrid,Azure Bicep,我是Azure二头肌的新手(我对它本身很陌生),但对ARM模板有一些经验 我正在尝试学习如何创建Azure日志存储容器的Azure事件网格订阅 这不是我一直在遵循的生产代码,我现在正尝试使用未涵盖的EventGrid 当我要部署使用bicep创建的模板时,我会遇到以下错误: { "error": { "code": "InvalidRequest", "message": &q

我是Azure二头肌的新手(我对它本身很陌生),但对ARM模板有一些经验

我正在尝试学习如何创建Azure日志存储容器的Azure事件网格订阅

这不是我一直在遵循的生产代码,我现在正尝试使用未涵盖的EventGrid

当我要部署使用bicep创建的模板时,我会遇到以下错误:

{
    "error": {
        "code": "InvalidRequest",
        "message": "Invalid event subscription request: Supplied URL is invalid. It cannot be null or empty and should be a proper HTTPS URL like https://www.example.com."
    }
}
我的事件网格订阅如下所示:

resource sub1 'Microsoft.EventGrid/systemTopics/eventSubscriptions@2020-04-01-preview' = {
    name: '${eventgrid.name}${subscriptionName}'
    properties: {
        destination: {
            properties: {
                maxEventsPerBatch: 1
                preferredBatchSizeInKilobytes: 64
            }
            endpointType: 'WebHook'
        }
        filter: {
            subjectBeginsWith: '/blobServices/default/containers/mycontainer'
            includedEventTypes: [
                'Microsoft.Storage.BlobCreated'
            ]
        }
        labels: []
        eventDeliverySchema: 'EventGridSchema'
        retryPolicy: {
            maxDeliveryAttempts: 30
            eventTimeToLiveInMinutes: 1440
        }
        topicType: 'Microsoft.Storage.StorageAccounts'
    }
}
resource sub1 'Microsoft.EventGrid/systemTopics/eventSubscriptions@2020-04-01-preview' = {
    name: '${eventgrid.name}${subscriptionName}'
    properties: {
        destination: {
            properties: {
                maxEventsPerBatch: 1
                preferredBatchSizeInKilobytes: 64
                endpointUrl: 'https://${storageAccount.name}.blob.core.windows.net/mycontainer'
            }
            endpointType: 'WebHook'
param location string = resourceGroup().location
param evgNamePrefix string = 'evg'
param subNamePrefix string = 'sub'
param stgNamePrefix string = 'stg'
param subOneName string = '/foo-local-debug'
param containerOneName string = '/mycontainer'
// param storageAccountName string = 'blee'

param globalRedundancy bool = true // defaults to true, but can be overridden

var storageAccountName = '${stgNamePrefix}${uniqueString(resourceGroup().id)}'
var eventGridName = '${evgNamePrefix}${uniqueString(resourceGroup().id)}'
var eventGridSubscriptionName = '${evgNamePrefix}${subNamePrefix}${uniqueString(resourceGroup().id)}${subOneName}'

resource evg 'Microsoft.EventGrid/systemTopics@2020-04-01-preview' = {
    name: eventGridName
    location: location
    properties: {
        source: stg.id
        topicType: 'Microsoft.Storage.StorageAccounts'
    }
}
resource sub1 'Microsoft.EventGrid/systemTopics/eventSubscriptions@2020-04-01-preview' = {
    name: '${evg.name}${subOneName}'
    properties: {
        destination: {
            properties: {
                maxEventsPerBatch: 1
                preferredBatchSizeInKilobytes: 64
                endpointUrl: 'https://${stg.name}.blob.core.windows.net/mycontainer'
            }
            endpointType: 'WebHook'
        }
        filter: {
            subjectBeginsWith: '/blobServices/default/containers/mycontainer'
            includedEventTypes: [
                'Microsoft.Storage.BlobCreated'
            ]
        }
        labels: []
        eventDeliverySchema: 'EventGridSchema'
        retryPolicy: {
            maxDeliveryAttempts: 30
            eventTimeToLiveInMinutes: 1440
        }
        topicType: 'Microsoft.Storage.StorageAccounts'
    }
}

resource stg 'Microsoft.Storage/storageAccounts@2019-06-01' = {
    name: storageAccountName
    location: location
    kind: 'StorageV2'
    sku: {
        name: globalRedundancy ? 'Standard_GRS' : 'Standard_LRS' // if true --> GRS, else --> LRS
    }
    properties: {
        azureFilesIdentityBasedAuthentication: {
            directoryServiceOptions: 'None'
        }
        largeFileSharesState: 'Disabled'
        networkAcls: {
            bypass: 'AzureServices'
            virtualNetworkRules: []
            ipRules: []
            defaultAction: 'Allow'
        }
        supportsHttpsTrafficOnly: true
        encryption: {
            services: {
                file: {
                    keyType: 'Account'
                    enabled: true
                }
                blob: {
                    keyType: 'Account'
                    enabled: true
                }
            }
            keySource: 'Microsoft.Storage'
        }
        accessTier:'Hot'
    }
}

resource bs 'Microsoft.Storage/storageAccounts/blobServices@2019-06-01' = {
    name: '${stg.name}/default'
    properties: { 
        cors: {
            corsRules: []
        }
        deleteRetentionPolicy: {
            enabled: true
            days: 7
        }
    }
    sku: {
        name: globalRedundancy ? 'Standard_GRS' : 'Standard_LRS' // if true --> GRS, else --> LRS
        tier: 'Standard'
    }   
} 

resource c1 'Microsoft.Storage/storageAccounts/blobServices/containers@2019-06-01' = {
  name: '${stg.name}/default${containerOneName}'
  properties: {
    defaultEncryptionScope:'$account-encryption-key'
    denyEncryptionScopeOverride: false
    publicAccess: 'None'
  }
}

output storageId string = stg.id
output computedStorageName string = stg.name
output eventGridId string = evg.id
output eventGridsName string = evg.name
将endpointUrl属性添加到事件订阅时,会出现不同的错误:

{
    "status": "Failed",
    "error": {
        "code": "ResourceDeploymentFailure",
        "message": "The resource operation completed with terminal provisioning state 'Failed'.",
        "details": [
            {
                "code": "Url validation",
                "message": "Webhook validation handshake failed for https://foobarblee.blob.core.windows.net/results-nlp. Http POST request failed with response code Unknown. For troublehooting, visit https://aka.ms/esvalidation. Activity id:, timestamp: 9/22/2020 11:21:07 PM (UTC)."
            }
        ]
    }
}
代码部分更改为如下所示:

resource sub1 'Microsoft.EventGrid/systemTopics/eventSubscriptions@2020-04-01-preview' = {
    name: '${eventgrid.name}${subscriptionName}'
    properties: {
        destination: {
            properties: {
                maxEventsPerBatch: 1
                preferredBatchSizeInKilobytes: 64
            }
            endpointType: 'WebHook'
        }
        filter: {
            subjectBeginsWith: '/blobServices/default/containers/mycontainer'
            includedEventTypes: [
                'Microsoft.Storage.BlobCreated'
            ]
        }
        labels: []
        eventDeliverySchema: 'EventGridSchema'
        retryPolicy: {
            maxDeliveryAttempts: 30
            eventTimeToLiveInMinutes: 1440
        }
        topicType: 'Microsoft.Storage.StorageAccounts'
    }
}
resource sub1 'Microsoft.EventGrid/systemTopics/eventSubscriptions@2020-04-01-preview' = {
    name: '${eventgrid.name}${subscriptionName}'
    properties: {
        destination: {
            properties: {
                maxEventsPerBatch: 1
                preferredBatchSizeInKilobytes: 64
                endpointUrl: 'https://${storageAccount.name}.blob.core.windows.net/mycontainer'
            }
            endpointType: 'WebHook'
param location string = resourceGroup().location
param evgNamePrefix string = 'evg'
param subNamePrefix string = 'sub'
param stgNamePrefix string = 'stg'
param subOneName string = '/foo-local-debug'
param containerOneName string = '/mycontainer'
// param storageAccountName string = 'blee'

param globalRedundancy bool = true // defaults to true, but can be overridden

var storageAccountName = '${stgNamePrefix}${uniqueString(resourceGroup().id)}'
var eventGridName = '${evgNamePrefix}${uniqueString(resourceGroup().id)}'
var eventGridSubscriptionName = '${evgNamePrefix}${subNamePrefix}${uniqueString(resourceGroup().id)}${subOneName}'

resource evg 'Microsoft.EventGrid/systemTopics@2020-04-01-preview' = {
    name: eventGridName
    location: location
    properties: {
        source: stg.id
        topicType: 'Microsoft.Storage.StorageAccounts'
    }
}
resource sub1 'Microsoft.EventGrid/systemTopics/eventSubscriptions@2020-04-01-preview' = {
    name: '${evg.name}${subOneName}'
    properties: {
        destination: {
            properties: {
                maxEventsPerBatch: 1
                preferredBatchSizeInKilobytes: 64
                endpointUrl: 'https://${stg.name}.blob.core.windows.net/mycontainer'
            }
            endpointType: 'WebHook'
        }
        filter: {
            subjectBeginsWith: '/blobServices/default/containers/mycontainer'
            includedEventTypes: [
                'Microsoft.Storage.BlobCreated'
            ]
        }
        labels: []
        eventDeliverySchema: 'EventGridSchema'
        retryPolicy: {
            maxDeliveryAttempts: 30
            eventTimeToLiveInMinutes: 1440
        }
        topicType: 'Microsoft.Storage.StorageAccounts'
    }
}

resource stg 'Microsoft.Storage/storageAccounts@2019-06-01' = {
    name: storageAccountName
    location: location
    kind: 'StorageV2'
    sku: {
        name: globalRedundancy ? 'Standard_GRS' : 'Standard_LRS' // if true --> GRS, else --> LRS
    }
    properties: {
        azureFilesIdentityBasedAuthentication: {
            directoryServiceOptions: 'None'
        }
        largeFileSharesState: 'Disabled'
        networkAcls: {
            bypass: 'AzureServices'
            virtualNetworkRules: []
            ipRules: []
            defaultAction: 'Allow'
        }
        supportsHttpsTrafficOnly: true
        encryption: {
            services: {
                file: {
                    keyType: 'Account'
                    enabled: true
                }
                blob: {
                    keyType: 'Account'
                    enabled: true
                }
            }
            keySource: 'Microsoft.Storage'
        }
        accessTier:'Hot'
    }
}

resource bs 'Microsoft.Storage/storageAccounts/blobServices@2019-06-01' = {
    name: '${stg.name}/default'
    properties: { 
        cors: {
            corsRules: []
        }
        deleteRetentionPolicy: {
            enabled: true
            days: 7
        }
    }
    sku: {
        name: globalRedundancy ? 'Standard_GRS' : 'Standard_LRS' // if true --> GRS, else --> LRS
        tier: 'Standard'
    }   
} 

resource c1 'Microsoft.Storage/storageAccounts/blobServices/containers@2019-06-01' = {
  name: '${stg.name}/default${containerOneName}'
  properties: {
    defaultEncryptionScope:'$account-encryption-key'
    denyEncryptionScopeOverride: false
    publicAccess: 'None'
  }
}

output storageId string = stg.id
output computedStorageName string = stg.name
output eventGridId string = evg.id
output eventGridsName string = evg.name
不幸的是,我找不到关于这个问题的任何文档

我的整个二头肌文件如下所示:

resource sub1 'Microsoft.EventGrid/systemTopics/eventSubscriptions@2020-04-01-preview' = {
    name: '${eventgrid.name}${subscriptionName}'
    properties: {
        destination: {
            properties: {
                maxEventsPerBatch: 1
                preferredBatchSizeInKilobytes: 64
            }
            endpointType: 'WebHook'
        }
        filter: {
            subjectBeginsWith: '/blobServices/default/containers/mycontainer'
            includedEventTypes: [
                'Microsoft.Storage.BlobCreated'
            ]
        }
        labels: []
        eventDeliverySchema: 'EventGridSchema'
        retryPolicy: {
            maxDeliveryAttempts: 30
            eventTimeToLiveInMinutes: 1440
        }
        topicType: 'Microsoft.Storage.StorageAccounts'
    }
}
resource sub1 'Microsoft.EventGrid/systemTopics/eventSubscriptions@2020-04-01-preview' = {
    name: '${eventgrid.name}${subscriptionName}'
    properties: {
        destination: {
            properties: {
                maxEventsPerBatch: 1
                preferredBatchSizeInKilobytes: 64
                endpointUrl: 'https://${storageAccount.name}.blob.core.windows.net/mycontainer'
            }
            endpointType: 'WebHook'
param location string = resourceGroup().location
param evgNamePrefix string = 'evg'
param subNamePrefix string = 'sub'
param stgNamePrefix string = 'stg'
param subOneName string = '/foo-local-debug'
param containerOneName string = '/mycontainer'
// param storageAccountName string = 'blee'

param globalRedundancy bool = true // defaults to true, but can be overridden

var storageAccountName = '${stgNamePrefix}${uniqueString(resourceGroup().id)}'
var eventGridName = '${evgNamePrefix}${uniqueString(resourceGroup().id)}'
var eventGridSubscriptionName = '${evgNamePrefix}${subNamePrefix}${uniqueString(resourceGroup().id)}${subOneName}'

resource evg 'Microsoft.EventGrid/systemTopics@2020-04-01-preview' = {
    name: eventGridName
    location: location
    properties: {
        source: stg.id
        topicType: 'Microsoft.Storage.StorageAccounts'
    }
}
resource sub1 'Microsoft.EventGrid/systemTopics/eventSubscriptions@2020-04-01-preview' = {
    name: '${evg.name}${subOneName}'
    properties: {
        destination: {
            properties: {
                maxEventsPerBatch: 1
                preferredBatchSizeInKilobytes: 64
                endpointUrl: 'https://${stg.name}.blob.core.windows.net/mycontainer'
            }
            endpointType: 'WebHook'
        }
        filter: {
            subjectBeginsWith: '/blobServices/default/containers/mycontainer'
            includedEventTypes: [
                'Microsoft.Storage.BlobCreated'
            ]
        }
        labels: []
        eventDeliverySchema: 'EventGridSchema'
        retryPolicy: {
            maxDeliveryAttempts: 30
            eventTimeToLiveInMinutes: 1440
        }
        topicType: 'Microsoft.Storage.StorageAccounts'
    }
}

resource stg 'Microsoft.Storage/storageAccounts@2019-06-01' = {
    name: storageAccountName
    location: location
    kind: 'StorageV2'
    sku: {
        name: globalRedundancy ? 'Standard_GRS' : 'Standard_LRS' // if true --> GRS, else --> LRS
    }
    properties: {
        azureFilesIdentityBasedAuthentication: {
            directoryServiceOptions: 'None'
        }
        largeFileSharesState: 'Disabled'
        networkAcls: {
            bypass: 'AzureServices'
            virtualNetworkRules: []
            ipRules: []
            defaultAction: 'Allow'
        }
        supportsHttpsTrafficOnly: true
        encryption: {
            services: {
                file: {
                    keyType: 'Account'
                    enabled: true
                }
                blob: {
                    keyType: 'Account'
                    enabled: true
                }
            }
            keySource: 'Microsoft.Storage'
        }
        accessTier:'Hot'
    }
}

resource bs 'Microsoft.Storage/storageAccounts/blobServices@2019-06-01' = {
    name: '${stg.name}/default'
    properties: { 
        cors: {
            corsRules: []
        }
        deleteRetentionPolicy: {
            enabled: true
            days: 7
        }
    }
    sku: {
        name: globalRedundancy ? 'Standard_GRS' : 'Standard_LRS' // if true --> GRS, else --> LRS
        tier: 'Standard'
    }   
} 

resource c1 'Microsoft.Storage/storageAccounts/blobServices/containers@2019-06-01' = {
  name: '${stg.name}/default${containerOneName}'
  properties: {
    defaultEncryptionScope:'$account-encryption-key'
    denyEncryptionScopeOverride: false
    publicAccess: 'None'
  }
}

output storageId string = stg.id
output computedStorageName string = stg.name
output eventGridId string = evg.id
output eventGridsName string = evg.name

我基于BICEP文档生成了ARMJSON。 我将Url更改为public webhook,它正在工作:

“端点URL”:https://eval-mm.azurewebsites.net/api/Function1"

EventGrid订阅WebHook必须是公共的,并且不支持URL参数或标题。这对我来说很烦人

享受二头肌,它是很棒的东西:-)


webhook必须公开:它不适合我