CrazyIter_Bin 11 tháng trước cách đây
mục cha
commit
80912f3a3d

+ 11 - 1
TEAMModelOS.Function/IESCosmosDBTrigger.cs

@@ -46,14 +46,24 @@ namespace TEAMModelOS.Function
             containerName: "Common",
             Connection = "Azure:Cosmos:ConnectionString",
             LeaseContainerName = "leases",
-            CreateLeaseContainerIfNotExists = true)] IReadOnlyList<JsonElement> input)
+            CreateLeaseContainerIfNotExists = true,StartFromBeginning =false)] IReadOnlyList<JsonElement> input)
         {
             if (input != null && input.Count > 0)
             {
                 _logger.LogInformation("Documents modified: " + input.Count);
                 _logger.LogInformation("First document Id: " +JsonSerializer.Serialize(input[0]));
                 var client = _azureCosmos.GetCosmosClient();
+
                 foreach (var element in input) {
+                    element.TryGetProperty("_ts", out JsonElement _ts);
+                    element.TryGetProperty("id", out JsonElement _id);
+                    //_logger.LogInformation($"过期数据=>时间戳:{_ts.GetInt64()}-id:{_id}");
+                    //return;
+
+                    //if (JsonValueKind.Number.Equals(_ts.ValueKind)  && 1719331200>_ts.GetInt64()) {
+                    //    _logger.LogInformation($"过期数据=>时间戳:{_ts.GetInt64()}-id:{_id}"   );
+                    //    return; 
+                    //}
                     _logger.LogInformation("变化参数 " + element);
                     element.TryGetProperty("pk", out JsonElement jsond);
                     if (!string.IsNullOrWhiteSpace($"{jsond}"))

+ 6 - 3
TEAMModelOS.Function/IESHttpTrigger.cs

@@ -69,7 +69,9 @@ namespace TEAMModelOS.Function
         public async Task<IActionResult> SystemInfo([HttpTrigger(AuthorizationLevel.Anonymous,  "post", Route = null)] HttpRequest req)
         {
             _logger.LogInformation("C# HTTP trigger function processed a request.");
-
+            // string data1 = await req.ReadBodyContentAsync();
+          
+            
             Type attr = this.GetType();
             string currentDirectory = Path.GetDirectoryName(attr.Assembly.Location);
             Assembly assembly = Assembly.LoadFrom($"{currentDirectory}\\TEAMModelOS.FunctionV4.dll");
@@ -92,14 +94,15 @@ namespace TEAMModelOS.Function
             return new OkObjectResult(new { version, description, nowtime });
         }
         [Function("surplus-space-notify")]
-        public   IActionResult SurplusSpaceNotify([HttpTrigger(AuthorizationLevel.Anonymous, "post", Route = null)] HttpRequest req)
+        public  async Task <IActionResult> SurplusSpaceNotify([HttpTrigger(AuthorizationLevel.Anonymous, "post", Route = null)] HttpRequest req)
         {
             string msg = "";
+            string data = await new StreamReader(req.Body).ReadToEndAsync();
             _backgroundWorkerQueue.QueueBackgroundWorkItem(async token =>
             {
                 try
                 {
-                    string data = await new StreamReader(req.Body).ReadToEndAsync();
+                  
                     var json = JsonDocument.Parse(data).RootElement;
                     json.TryGetProperty("name", out JsonElement _name);
                     json.TryGetProperty("scope", out JsonElement _scope);

+ 2 - 2
TEAMModelOS.Function/Program.cs

@@ -11,8 +11,8 @@ var host = new HostBuilder()
     .ConfigureFunctionsWebApplication()
     .ConfigureServices((context, services) =>
     {
-        services.AddApplicationInsightsTelemetryWorkerService();
-        services.ConfigureFunctionsApplicationInsights();
+        //services.AddApplicationInsightsTelemetryWorkerService();
+        //services.ConfigureFunctionsApplicationInsights();
 
 
 

+ 9 - 0
TEAMModelOS.Function/Properties/serviceDependencies.TEAMModelOSFunction - Zip Deploy.json

@@ -0,0 +1,9 @@
+{
+  "dependencies": {
+    "storage1": {
+      "resourceId": "/subscriptions/[parameters('subscriptionId')]/resourceGroups/[parameters('resourceGroupName')]/providers/Microsoft.Storage/storageAccounts/teammodellog",
+      "type": "storage.azure",
+      "connectionId": "AzureWebJobsStorage"
+    }
+  }
+}

+ 4 - 3
TEAMModelOS.Function/TEAMModelOS.Function.csproj

@@ -31,14 +31,15 @@
   <ItemGroup>
     <FrameworkReference Include="Microsoft.AspNetCore.App" />
     <PackageReference Include="Microsoft.Azure.Functions.Worker" Version="1.22.0" />
-    <PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.CosmosDB" Version="4.0.0-preview2" />
+    <!--<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.CosmosDB" Version="4.0.0-preview2" />-->
+	<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.CosmosDB" Version="4.3.0" />
     <PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Http" Version="3.2.0" />
     <PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Http.AspNetCore" Version="1.3.2" />
     <PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.ServiceBus" Version="5.20.0" />
     <PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Timer" Version="4.3.1" />
     <PackageReference Include="Microsoft.Azure.Functions.Worker.Sdk" Version="1.17.1" />
-    <PackageReference Include="Microsoft.ApplicationInsights.WorkerService" Version="2.22.0" />
-    <PackageReference Include="Microsoft.Azure.Functions.Worker.ApplicationInsights" Version="1.2.0" />
+    <!--<PackageReference Include="Microsoft.ApplicationInsights.WorkerService" Version="2.22.0" />
+    <PackageReference Include="Microsoft.Azure.Functions.Worker.ApplicationInsights" Version="1.2.0" />-->
   </ItemGroup>
   <ItemGroup>
     <ProjectReference Include="..\TEAMModelOS.SDK\TEAMModelOS.SDK.csproj" />