11import { CdnManagementClient } from "@azure/arm-cdn" ;
22import { CosmosClient } from "@azure/cosmos" ;
3- import { app } from "@azure/functions" ;
3+ import { app , output } from "@azure/functions" ;
44import { DefaultAzureCredential } from "@azure/identity" ;
55import { BlobServiceClient } from "@azure/storage-blob" ;
66import { QueueServiceClient } from "@azure/storage-queue" ;
@@ -10,6 +10,7 @@ import { Crypto } from "@peculiar/webcrypto";
1010import * as E from "fp-ts/Either" ;
1111import { identity , pipe } from "fp-ts/function" ;
1212import * as t from "io-ts" ;
13+ import { WalletInstance } from "io-wallet-common/wallet-instance" ;
1314
1415import { getCrlFromUrl } from "@/certificates" ;
1516import { CosmosDbCertificateRepository } from "@/infra/azure/cosmos/certificate" ;
@@ -26,6 +27,7 @@ import { GetCurrentWalletInstanceStatusFunction } from "@/infra/azure/functions/
2627import { GetNonceFunction } from "@/infra/azure/functions/get-nonce" ;
2728import { GetWalletInstanceStatusFunction } from "@/infra/azure/functions/get-wallet-instance-status" ;
2829import { HealthFunction } from "@/infra/azure/functions/health" ;
30+ import { MigrateWalletInstancesFunction } from "@/infra/azure/functions/migrate-wallet-instances" ;
2931import { SendEmailOnWalletInstanceCreationFunction } from "@/infra/azure/functions/send-email-on-wallet-instance-creation" ;
3032import { SendEmailOnWalletInstanceRevocationFunction } from "@/infra/azure/functions/send-email-on-wallet-instance-revocation" ;
3133import { SetWalletInstanceStatusFunction } from "@/infra/azure/functions/set-wallet-instance-status" ;
@@ -299,3 +301,22 @@ app.http("generateCertificateChain", {
299301 methods : [ "POST" ] ,
300302 route : "certificate-chain" ,
301303} ) ;
304+
305+ app . cosmosDB ( "migrateWalletInstances" , {
306+ connection : "PagoPACosmosDbConnectionString" ,
307+ containerName : "wallet-instances" ,
308+ createLeaseCollectionIfNotExists : true ,
309+ databaseName : "db" ,
310+ handler : MigrateWalletInstancesFunction ( {
311+ inputDecoder : t . array ( WalletInstance ) ,
312+ } ) ,
313+ leaseContainerName : "leases-migration" ,
314+ maxItemsPerInvocation : 50 ,
315+ return : output . cosmosDB ( {
316+ connection : "CosmosDbEndpoint" ,
317+ containerName : "wallet-instances" ,
318+ createIfNotExists : false ,
319+ databaseName : "db" ,
320+ } ) ,
321+ startFromBeginning : true ,
322+ } ) ;
0 commit comments