I am trying to migrated data from one collection to another using azure functions Cosmos trigger. I have set StartFromBeginning=True. I have multiple collections to migrate so I use one function per collection so transfer happens fast.
When I deploy the function it show the status has Running but it actually does not start the transfer unless I to a stop and start. Or if I go to the monitor section and go to live metrics then it start. Is there a way for it to start transferring as soon as it is deployed. Am I messing a setting?
For example I deployed a function yesterday night and today morning when I looked at the count of recoreds in the collection there was none. When I went to Monitor section in Azure functions and then to Live app metrics then only I see it initializing and then starts to execute.
Cosmos Trigger
public async Task Run([CosmosDBTrigger(
databaseName: "%SourceDatabaseName%",
collectionName: "%ContainerName%",
ConnectionStringSetting = "connectionString",
StartFromBeginning =true,
LeaseCollectionName ="%ContainerLeaseName%",
CreateLeaseCollectionIfNotExists = true)]IReadOnlyList<Document> source,
[CosmosDB(databaseName:"%TargetDatabaseName%",
collectionName:"%TargetContainerName%",
ConnectionStringSetting = "connectionString")]IAsyncCollector<Document> destination,
ILogger log)
Deploy Script
az functionapp create `
-n $functionAppName `
--storage-account $storageAccountName `
--consumption-plan-location $location `
--app-insights $appInsightsName `
--runtime dotnet `
-g $resourceGroup
az functionapp deployment source config-zip `
-g $resourceGroup -n $functionAppName --src $publishZip
az functionapp config appsettings set -n $functionAppName -g $resourceGroup `
--settings "connectionString=$cosmosConnectionString" "ContainerName=$cosmosContainer" "ContainerLeaseName=$($cosmosContainer)Lease" "SourceDatabaseName=$sourceCosmosDb" "TargetDatabaseName=$destCosmosDb" "TargetContainerName=$cosmosContainer" "JobType=$jobType"