Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [FunctionName("'")]
- public static void Run([EventGridTrigger]EventGridEvent eventGridEvent, ILogger log)
- {
- Logger.instace.Init(log);
- log.LogInformation(eventGridEvent.Data.ToString());
- JsonApi jsonApi = Newtonsoft.Json.JsonConvert.DeserializeObject<JsonApi>(eventGridEvent.Data.ToString());
- if(jsonApi.contentType == "text/xml")
- TakeCareFile(jsonApi);
- }
- public static async void TakeCareFile(JsonApi jsonApi)
- {
- string connectionString = Static.AccessKey;//Environment.GetEnvironmentVariable();
- string destinationFile = jsonApi.url.Split('/')[4];
- CloudStorageAccount storageAccount;
- if (CloudStorageAccount.TryParse(connectionString, out storageAccount))
- {
- CloudBlobClient cloudBlobClient = storageAccount.CreateCloudBlobClient();
- CloudBlobContainer cloudBlobContainer = cloudBlobClient.GetContainerReference("ids");
- await cloudBlobContainer.CreateIfNotExistsAsync();
- CloudBlockBlob cloudBlockBlob = cloudBlobContainer.GetBlockBlobReference(destinationFile);
- Console.WriteLine("Downloading blob to {0}", destinationFile);
- Stream Read = await cloudBlockBlob.OpenReadAsync();
- //await cloudBlockBlob.DownloadToFileAsync(destinationFile, FileMode.Create);
- using var sr = new StreamReader(Read, Encoding.UTF8);
- string line = String.Empty;
- string XMLdata=sr.ReadToEnd();
- await cloudBlockBlob.DeleteIfExistsAsync();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment