CrazyIter_Bin 3 tahun lalu
induk
melakukan
93c6eb7d19

+ 9 - 3
FunctionApp1/Function1.cs

@@ -12,6 +12,7 @@ using System.Net;
 using TEAMModelOS.SDK.DI;
 using TEAMModelOS.SDK.Models;
 using TEAMModelOS.SDK.Extension;
+using System.Text.Json;
 
 namespace FunctionApp1
 {
@@ -29,17 +30,22 @@ namespace FunctionApp1
             Connection =    "Azure:Cosmos:ConnectionString",
             LeaseContainerName = "leases",
             LeaseContainerPrefix = "TEAMModelOS",
-            CreateLeaseContainerIfNotExists =true)]Vote vote, ILogger log)
+            CreateLeaseContainerIfNotExists =true)]string data, ILogger log)
         {
             try {
                 var teacher = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Teacher").ReadItemAsync<Teacher>("1595321354", new Azure.Cosmos.PartitionKey("Base"));
                 Console.WriteLine(teacher.ToJsonString());
-                Console.WriteLine(vote.ToJsonString());
+                Console.WriteLine(data);
             } catch (Exception ex) {
                 Console.WriteLine($"{ex.Message}{ex.StackTrace}");
             }
         }
-
+       
+        [Function("GroupChange")]
+        public async Task GroupChangeFunc([ServiceBusTrigger("%Azure:ServiceBus:ActiveTask%", "group-change", Connection = "Azure:ServiceBus:ConnectionString")] string msg) {
+            var teacher = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Teacher").ReadItemAsync<Teacher>("1595321354", new Azure.Cosmos.PartitionKey("Base"));
+            Console.WriteLine(msg);
+        }
         [Function("Function1")]
         public   async Task<HttpResponseData> Run(
             [HttpTrigger(AuthorizationLevel.Anonymous, "get", "post", Route = null)] HttpRequestData req,

+ 1 - 0
FunctionApp1/Program.cs

@@ -34,6 +34,7 @@ namespace TEAMModelOS.FunctionV4
                services.AddAzureCosmos(context.Configuration.GetSection("Azure:Cosmos:ConnectionString").Get<string>());
            })
            .Build();
+            var s = Environment.GetEnvironmentVariable("Azure:ServiceBus:ActiveTask");
             await host.RunAsync();
         }
     }

+ 4 - 1
FunctionApp1/local.settings.json

@@ -3,7 +3,10 @@
   "Values": {
     "AzureWebJobsStorage": "DefaultEndpointsProtocol=https;AccountName=teammodellog;AccountKey=lxVDrgs+6rKtmASL3k1WrarrEd5Rk42wS1Mu5+sqQlPya1JLSlFDtnZUvMPeHHe7zlESfn/1NY7CZdGviy2UCw==;EndpointSuffix=core.chinacloudapi.cn",
     "FUNCTIONS_WORKER_RUNTIME": "dotnet-isolated",
-    "Azure:Cosmos:ConnectionString": "AccountEndpoint=https://cdhabookdep-free.documents.azure.cn:443/;AccountKey=JTUVk92Gjsx17L0xqxn0X4wX2thDPMKiw4daeTyV1HzPb6JmBeHdtFY1MF1jdctW1ofgzqkDMFOtcqS46by31A==;"
+    "Azure:Cosmos:ConnectionString": "AccountEndpoint=https://cdhabookdep-free.documents.azure.cn:443/;AccountKey=JTUVk92Gjsx17L0xqxn0X4wX2thDPMKiw4daeTyV1HzPb6JmBeHdtFY1MF1jdctW1ofgzqkDMFOtcqS46by31A==;",
+    "Azure:ServiceBus:ConnectionString": "Endpoint=sb://teammodelos.servicebus.chinacloudapi.cn/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=Sy4h4EQ8zP+7w/lOLi1X3tGord/7ShFHimHs1vC50Dc=",
+    "Azure:ServiceBus:ActiveTask": "dep-active-task",
+    "Azure:ServiceBus:ItemCondQueue": "dep-itemcond"
   },
   "AzureWebJobsStorage": "DefaultEndpointsProtocol=https;AccountName=teammodellog;AccountKey=lxVDrgs+6rKtmASL3k1WrarrEd5Rk42wS1Mu5+sqQlPya1JLSlFDtnZUvMPeHHe7zlESfn/1NY7CZdGviy2UCw==;EndpointSuffix=core.chinacloudapi.cn",
   "Option": {

+ 0 - 1
TEAMModelOS.FunctionV4/local.settings.json

@@ -11,7 +11,6 @@
     "Azure:Cosmos:ConnectionString": "AccountEndpoint=https://cdhabookdep-free.documents.azure.cn:443/;AccountKey=JTUVk92Gjsx17L0xqxn0X4wX2thDPMKiw4daeTyV1HzPb6JmBeHdtFY1MF1jdctW1ofgzqkDMFOtcqS46by31A==;",
     "Azure:Redis:ConnectionString": "106.12.23.251:6379,password=habook,ssl=false,abortConnect=False,writeBuffer=10240",
     "Azure:ServiceBus:ActiveTask": "dep-active-task",
-    "Azure:ServiceBus:NoticeTask": "dep-notice-task",
     "Azure:ServiceBus:ItemCondQueue": "dep-itemcond",
     "Option:Location": "China-Dep",
     "FUNCTIONS_WORKER_RUNTIME": "dotnet",