在Azure上为Azure Python函数设置CI/CD管道



我正在尝试使用Azure DevOps管道为Azure Python函数构建CI/CD管道。我主要尝试遵循以下教程:https://medium.com/bb-tutorials-and-thoughts/how-to-build-ci-cd-for-python-azure-functions-using-azure-devops-7087a76e535b

但是我遇到的一个问题是,在同一个存储库中,我有多个Azure函数的代码。例如,

| - app 
| - microservices
|    | - azure_func1
|    | - azure_func2
|    | - azure_func3
|    | - azure_func4

在每个Azure Function文件夹中,我有必要的文件(例如主机。json,代理。Json、requirements.txt等)。当设置管道时,我似乎找不到一个允许我指定构建管道应该从哪个目录获取代码并构建到Azure Artifacts的字段。

请建议!

Azure功能App有多个配置来管理应用于所有功能的功能App实例,这里是host。Json是存放所有这些配置的元数据文件。

host中的配置。与绑定相关的Json会平等地应用于函数应用中的每个函数。

在主机上。在Json中,我们可以指定可以应用这些设置的函数的数量,以便在特定配置中只考虑这些函数。如果这个数组是空的,那么这将应用于函数app中的整个函数。

{
"functions": [ "function1", "function2" ]
}
下面是示例host.json:
{
"version": "2.0",
"aggregator": {
"batchSize": 1000,
"flushTimeout": "00:00:30"
},
"extensions": {
"blobs": {},
"cosmosDb": {},
"durableTask": {},
"eventHubs": {},
"http": {},
"queues": {},
"sendGrid": {},
"serviceBus": {}
},
"extensionBundle": {
"id": "Microsoft.Azure.Functions.ExtensionBundle",
"version": "[1.*, 2.0.0)"
},
"functions": [ "QueueProcessor", "GitHubWebHook" ],
"functionTimeout": "00:05:00",
"healthMonitor": {
"enabled": true,
"healthCheckInterval": "00:00:10",
"healthCheckWindow": "00:02:00",
"healthCheckThreshold": 6,
"counterThreshold": 0.80
},
"logging": {
"fileLoggingMode": "debugOnly",
"logLevel": {
"Function.MyFunction": "Information",
"default": "None"
},
"applicationInsights": {
"samplingSettings": {
"isEnabled": true,
"maxTelemetryItemsPerSecond" : 20,
"evaluationInterval": "01:00:00",
"initialSamplingPercentage": 100.0, 
"samplingPercentageIncreaseTimeout" : "00:00:01",
"samplingPercentageDecreaseTimeout" : "00:00:01",
"minSamplingPercentage": 0.1,
"maxSamplingPercentage": 100.0,
"movingAverageRatio": 1.0,
"excludedTypes" : "Dependency;Event",
"includedTypes" : "PageView;Trace"
},
"enableLiveMetrics": true,
"enableDependencyTracking": true,
"enablePerformanceCountersCollection": true,            
"httpAutoCollectionOptions": {
"enableHttpTriggerExtendedInfoCollection": true,
"enableW3CDistributedTracing": true,
"enableResponseHeaderInjection": true
},
"snapshotConfiguration": {
"agentEndpoint": null,
"captureSnapshotMemoryWeight": 0.5,
"failedRequestLimit": 3,
"handleUntrackedExceptions": true,
"isEnabled": true,
"isEnabledInDeveloperMode": false,
"isEnabledWhenProfiling": true,
"isExceptionSnappointsEnabled": false,
"isLowPrioritySnapshotUploader": true,
"maximumCollectionPlanSize": 50,
"maximumSnapshotsRequired": 3,
"problemCounterResetInterval": "24:00:00",
"provideAnonymousTelemetry": true,
"reconnectInterval": "00:15:00",
"shadowCopyFolder": null,
"shareUploaderProcess": true,
"snapshotInLowPriorityThread": true,
"snapshotsPerDayLimit": 30,
"snapshotsPerTenMinutesLimit": 1,
"tempFolder": null,
"thresholdForSnapshotting": 1,
"uploaderProxy": null
}
}
},
"managedDependency": {
"enabled": true
},
"retry": {
"strategy": "fixedDelay",
"maxRetryCount": 5,
"delayInterval": "00:00:05"
},
"singleton": {
"lockPeriod": "00:00:15",
"listenerLockPeriod": "00:01:00",
"listenerLockRecoveryPollingInterval": "00:01:00",
"lockAcquisitionTimeout": "00:01:00",
"lockAcquisitionPollingInterval": "00:00:03"
},
"watchDirectories": [ "Shared", "Test" ],
"watchFiles": [ "myFile.txt" ]
}

另外,如果我们想根据您的要求禁用不触发的功能,我们可以在local.settings.json中添加值"AzureWebJobs.HttpExample.Disabled": true

示例如下:

{
"IsEncrypted": false,
"Values": {
"FUNCTIONS_WORKER_RUNTIME": "python",
"AzureWebJobsStorage": "UseDevelopmentStorage=true", 
"AzureWebJobs.HttpExample.Disabled": true
}
}

更多信息请参考MS Docs

相关内容

  • 没有找到相关文章

最新更新