title: Webhook Url for Azure EventGrid Subscription with Azure Bicep Fails
body: <p>I'm new to Azure Bicep (which in itself i pretty new) but have some experience with ARM templates.</p>
  <p>I'm trying to learn how to create an Azure Event Grid subscription to an Azure Blog storage container.</p>
  <p>This is not production code I've been following this <a href="https://github.com/Azure/bicep/blob/master/docs/tutorial/01-simple-template.md" rel="nofollow noreferrer">tutorial</a> and am now trying to work with an EventGrid which is not covered.</p>
  <p>When I go to deploy my template created with bicep I get the error:</p>
  <pre><code>{
      &quot;error&quot;: {
          &quot;code&quot;: &quot;InvalidRequest&quot;,
          &quot;message&quot;: &quot;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.&quot;
      }
  }
  </code></pre>
  <p>My event grid subscription looks like this:</p>
  <pre><code>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'
      }
  }
  </code></pre>
  <p>When I add an endpointUrl property to the event subscription, I get a different error:</p>
  <pre><code>{
      &quot;status&quot;: &quot;Failed&quot;,
      &quot;error&quot;: {
          &quot;code&quot;: &quot;ResourceDeploymentFailure&quot;,
          &quot;message&quot;: &quot;The resource operation completed with terminal provisioning state 'Failed'.&quot;,
          &quot;details&quot;: [
              {
                  &quot;code&quot;: &quot;Url validation&quot;,
                  &quot;message&quot;: &quot;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).&quot;
              }
          ]
      }
  }
  </code></pre>
  <p>The section of code is changed to look like this:</p>
  <pre><code>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'
  </code></pre>
  <p>Unfortunately I can't find any documentation on this particular issue.</p>
  <p>My entire bicep file looks like this:</p>
  <pre><code>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 --&gt; GRS, else --&gt; 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 --&gt; GRS, else --&gt; 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
  </code></pre>