bicep icon indicating copy to clipboard operation
bicep copied to clipboard

functionapp:appSettings is formatting date incorrectly

Open kkilton opened this issue 11 months ago • 1 comments

Bicep version v0.25.53

Describe the bug In the below bicep example, I added a new appSetting named startFromTime which is used for a the cosmos db trigger. It's used here in the first code block below. When I run locally, with an env var or local.settings.json, the function runs perfectly. When I deploy the bicep though, it's formatting the date with slashes. Shouldn't this just be treated as a string and not formatted? When it's formatted, the function gives me a generic error. Please don't try and format this date. I have to manually make the change back to the correct format each time I deploy my bicep file.

I talked to MS tech support and he was able to see more information than I was able to see in my traces on app insights. He was able to see the actual error which said the StartFromTime was unable to be parsed. I would like to see the actual error (screenshot), not just a generic error that doesn't help, in my app insights. image

[FunctionName("FinancialChangeFeedProcessor")]
 public async Task Run([CosmosDBTrigger(
     databaseName: "%cosmosDbName%",
     containerName: "Financial",
     Connection = "ConnectionStrings:CosmosDB-NLP", //this will read from your secrets file, local.settings.json, or environment variables
     LeaseContainerName = "FinancialLeaseCollection",
     LeaseContainerPrefix = "%leaseContainerPrefix%",
     CreateLeaseContainerIfNotExists = true,
     StartFromTime = "%startFromTime%")]IReadOnlyCollection<JObject> documents)

To Reproduce

resource functionApp 'Microsoft.Web/sites@2021-03-01' = {
  name: functionAppName
  location: location
  kind: 'functionapp'
  identity: {
    type: 'SystemAssigned'
  }
  properties: {
    serverFarmId: hostingPlanId
    siteConfig: {
      vnetRouteAllEnabled: isPremium
      appSettings: [
        {
          name: 'AzureWebJobsStorage'
          value: 'DefaultEndpointsProtocol=https;AccountName=${storageAccountName};EndpointSuffix=${environment().suffixes.storage};AccountKey=${storageAccount.listKeys().keys[0].value}'
        }
        {
		  name: 'startFromTime'
		  value: '2024-02-20T00:00:00Z'
        }
      ]
      ftpsState: 'FtpsOnly'
      minTlsVersion: '1.2'
    }
    httpsOnly: true
  }
  tags: commonTags
}

Deploy this bicep using CLI.

Additional context Add any other context about the problem here.

kkilton avatar Mar 04 '24 17:03 kkilton

Can you provide more details about this? In what format was the startFromTime sent to the function app? It seems like the placeholder isn't being resolved, but Bicep or the deployment engine doesn't change the data going through it.

majastrz avatar Mar 06 '24 20:03 majastrz

this is happening to me. Basically the bicep for appsettings is auto reformatting my datetime

j03INTHECLOUD avatar Mar 13 '24 21:03 j03INTHECLOUD

the startFromTime is suppose to be ISO 8601, I put a string literal and try to use dateTimeFromEpoch which converts to ISO 8601 and your app setting bicep still auto converts it.

j03INTHECLOUD avatar Mar 13 '24 21:03 j03INTHECLOUD

Hi @kkilton, this issue has been marked as stale because it was labeled as requiring author feedback but has not had any activity for 7 days. It will be closed if no further activity occurs within 3 days of this comment. Thanks for contributing to bicep! :smile: :mechanical_arm: