Skip to content

Commit

Permalink
created data cleanup project (#4548)
Browse files Browse the repository at this point in the history
* created data cleanup project

* set correct project guid

* updated timer

Co-authored-by: Stephanie Buadu <[email protected]>
  • Loading branch information
acn-sbuad and Stephanie Buadu authored Jul 27, 2020
1 parent c66a1ac commit e2378a3
Show file tree
Hide file tree
Showing 9 changed files with 155 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Altinn.Platform.Storage.Uni
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Altinn.Platform.Storage.CosmosBackup", "CosmosBackup\Altinn.Platform.Storage.CosmosBackup.csproj", "{E484AEDD-0708-4C1A-B77A-4239251D524A}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Altinn.Platform.Storage.DataCleanup", "DataCleanup\Altinn.Platform.Storage.DataCleanup.csproj", "{3F69C9C9-D602-490C-B2BA-A5FB27E363EE}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -45,6 +47,10 @@ Global
{E484AEDD-0708-4C1A-B77A-4239251D524A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E484AEDD-0708-4C1A-B77A-4239251D524A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E484AEDD-0708-4C1A-B77A-4239251D524A}.Release|Any CPU.Build.0 = Release|Any CPU
{3F69C9C9-D602-490C-B2BA-A5FB27E363EE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3F69C9C9-D602-490C-B2BA-A5FB27E363EE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3F69C9C9-D602-490C-B2BA-A5FB27E363EE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3F69C9C9-D602-490C-B2BA-A5FB27E363EE}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<AzureFunctionsVersion>v3</AzureFunctionsVersion>
<!-- SonarCloud needs this -->
<ProjectGuid>{3F69C9C9-D602-490C-B2BA-A5FB27E363EE}</ProjectGuid>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Azure.Storage.Blobs" Version="12.4.4" />
<PackageReference Include="Microsoft.ApplicationInsights" Version="2.14.0" />
<PackageReference Include="Microsoft.NET.Sdk.Functions" Version="3.0.3" />
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>

<PropertyGroup Condition="'$(Configuration)'=='Debug'">
<CodeAnalysisRuleSet>..\Altinn3.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>

<ItemGroup Condition="'$(Configuration)'=='Debug'">
<AdditionalFiles Include="..\stylecop.json">
<Link>stylecop.json</Link>
</AdditionalFiles>
</ItemGroup>

<PropertyGroup>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<NoWarn>$(NoWarn);1591</NoWarn>
</PropertyGroup>

<ItemGroup>
<None Update="host.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="local.settings.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToPublishDirectory>Never</CopyToPublishDirectory>
</None>
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using System;

using Microsoft.Azure.WebJobs;
using Microsoft.Extensions.Logging;

namespace Altinn.Platform.Storage.DataCleanup
{
/// <summary>
/// Azure Function class for handling tasks related to nightly data cleanup.
/// </summary>
public class NightlyCleanup
{
/// <summary>
/// Runs nightly cleanup.
/// </summary>
/// <param name="timer">The trigger timer.</param>
/// <param name="log">The log</param>
[FunctionName("NightlyCleanup")]
public static void Run([TimerTrigger("0 0 */1 * * 1-5")]TimerInfo timer, ILogger log)
{
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace Altinn.Platform.Storage.DataCleanup.Services
{
public static class BlobService
{
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace Altinn.Platform.Storage.DataCleanup.Services
{
public static class CosmosService
{
}
}
21 changes: 21 additions & 0 deletions src/Altinn.Platform/Altinn.Platform.Storage/DataCleanup/Startup.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using Microsoft.ApplicationInsights.Extensibility;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Hosting;
using Microsoft.Extensions.DependencyInjection.Extensions;

namespace Altinn.Platform.Storage.DataCleanup
{
/// <summary>
/// The data cleanup startup
/// </summary>
public class Startup : IWebJobsStartup
{
/// <summary>
/// Gets data cleanup project configuration
/// </summary>
public void Configure(IWebJobsBuilder builder)
{
builder.Services.TryAddSingleton<ITelemetryInitializer, TelemetryInitializer>();
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using Microsoft.ApplicationInsights.Channel;
using Microsoft.ApplicationInsights.Extensibility;

namespace Altinn.Platform.Storage.DataCleanup
{
/// <summary>
/// Class that handles initialization of App Insights telemetry
/// </summary>
public class TelemetryInitializer : ITelemetryInitializer
{
/// <summary>
/// Initializer.
/// </summary>
/// <param name="telemetry">The telemetry</param>
public void Initialize(ITelemetry telemetry)
{
// set custom role name here
telemetry.Context.Cloud.RoleName = "Storage Data Cleanup";
}
}
}
15 changes: 15 additions & 0 deletions src/Altinn.Platform/Altinn.Platform.Storage/DataCleanup/host.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"version": "2.0",
"logging": {
"applicationInsights": {
"samplingExcludedTypes": "Request",
"samplingSettings": {
"isEnabled": true
}
},
"logLevel": {
"default": "Information",
"Function": "Information"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"IsEncrypted": false,
"Values": {
"AzureWebJobsStorage": "UseDevelopmentStorage=true",
"FUNCTIONS_WORKER_RUNTIME": "dotnet"
}
}

0 comments on commit e2378a3

Please sign in to comment.