Beispiel #1
0
        public async Task FindUpcoming(
            [TimerTrigger("%FindUpcomingSchedule%")] TimerInfo timer,
            [Queue("%ResourceGroupNotifyQueueName%", Connection = "MainStorageConnection")] IAsyncCollector <ResourceSearchResult> outboundQueue
            )
        {
            _log.LogTrace($"ScannerUpcomingDeletion timer past due: {timer.IsPastDue}; next run: {timer.Schedule.GetNextOccurrence(DateTime.UtcNow)}");
            var resourcesNearDeletion = await _scanner.ScanForExpiredResources(DateTime.UtcNow);

            // output to notification queue -->
            var resourcesToTag = resourcesNearDeletion.Select(x => new ResourceSearchResult(
                                                                  subscriptionId: x.SubscriptionId,
                                                                  resourceId: x.ResourceId
                                                                  ));
            await outboundQueue.AddRangeAsync(resourcesToTag);
        }
Beispiel #2
0
        public async Task FindUntaggedResources([TimerTrigger("0 */5 * * * *")] TimerInfo timer,
                                                [Queue("%ResourceGroupCreatedQueueName%", Connection = "MainStorageConnection")] IAsyncCollector <TagSuiteModel> outboundQueue
                                                )
        {
            _log.LogTrace($"ScannerUntagged timer past due: {timer.IsPastDue}; next run: {timer.Schedule.GetNextOccurrence(DateTime.UtcNow)}");
            var untaggedResources = await _scanner.ScanForUntaggedResources();

            // output to tag queue -->
            var resourcesToTag = untaggedResources.Select(x => new TagSuiteModel(
                                                              subscriptionId: x.SubscriptionId,
                                                              groupName: x.ResourceId,
                                                              managementDate: DateTime.UtcNow,
                                                              user: "******"
                                                              ));
            await outboundQueue.AddRangeAsync(resourcesToTag);
        }