public async Task Run([TimerTrigger("0 */5 * * * *")] TimerInfo myTimer) { try { CloudBlobClient cloudBlobClient = AzureStorageHelpers.ConnectToBlobClient(_config[Settings.STORAGE_ACCOUNT_NAME], _config[Settings.STORAGE_ACCOUNT_KEY]); CloudBlobContainer cloudBlobContainer = AzureStorageHelpers.GetBlobContainer(cloudBlobClient, _config[Settings.MODEL_CONTAINER_NAME]); // TODO: Can we download these from Blob Storage instead? string testDataPath = Path.Combine(Environment.CurrentDirectory, "Data", "taxi-fare-test.csv"); string trainDataPath = Path.Combine(Environment.CurrentDirectory, "Data", "taxi-fare-train.csv"); string modelPath = _config[Settings.MODEL_PATH]; await ModelTrainerHelpers.TrainAndSaveModel( _mlContext, trainDataPath, testDataPath, modelPath, cloudBlobContainer); } catch (Exception ex) { _logger.LogError($"Something went wrong. Exception thrown: {ex.Message}"); throw; } }
void IIngestedRepos.SaveTestData(InProcessFeedMsg msg) { TestDataEntity msgEntity = null; string moreExInfo = string.Empty; try { msgEntity = MakeTestDataEntity(msg); // TODO 5-23-15 Failsafe requires using Transient Fault application block and // maybe circuit breaker pattern on all requests for cloud services. Wrap below // code in that stuff as an example. AzureStorageHelpers.AzTableStorageInsert(ConstantsNEnums.TestMessageTableName, msgEntity); } catch (StorageException ex) { if (ex.Message.Contains("409")) { moreExInfo = "\n HTTP 409 error code: RowKey already exists in table on insert."; } string displayMsg = string.Format("\n{0}.SaveTestData():", m_ThisName); ConsoleNTraceHelpers.DisplayExToConsoleNTrace(displayMsg, ex); ConsoleNTraceHelpers.DisplayInfoToConsoleNTrace(moreExInfo); throw; } catch (Exception ex) { string displayMsg = string.Format("\n{0}.SaveTestData():", m_ThisName); ConsoleNTraceHelpers.DisplayExToConsoleNTrace(displayMsg, ex); throw; } }
public async Task WhenNewRequestFindsUpdatedBlob_ThenRequestReturnsFalse() { var payloadStringA = new string('a', 50); var payloadStringB = new string('b', 50); var payloadStringC = new string('c', 50); var payloadStringD = new string('d', 50); Assert.True( await _sut.WriteAsync( new[] { TestUtilities.CreateBlockData(payloadStringA, BlockSize), TestUtilities.CreateBlockData(payloadStringB, BlockSize) }, CancellationToken.None)); await AzureStorageHelpers.TouchBlobAsync(GetContainer().GetBlockBlobReference(Prefix + "0")); Assert.False( await _sut.WriteAsync( new[] { TestUtilities.CreateBlockData(payloadStringC, BlockSize), TestUtilities.CreateBlockData(payloadStringD, BlockSize) }, CancellationToken.None)); Assert.Equal( payloadStringA + payloadStringB, await GetContainer() .GetBlockBlobReference(Prefix + "0") .DownloadTextAsync(Encoding.UTF8, AccessCondition.GenerateEmptyCondition(), null, null)); }