public static async Task <HttpResponseMessage> Run([HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = "GetPowerShellTrigger")] HttpRequestMessage req, TraceWriter log)
        {
            var data = await req.Content.ReadAsStringAsync();

            var azureDetails = JsonConvert.DeserializeObject <AzureDetails>(data);

            SavePair(azureDetails.PairName, azureDetails.ProductionConnection, azureDetails.BackupConnection);

            AddMessage.Send(JsonConvert.SerializeObject(new AzureDetails()
            {
                ResourceGroup = azureDetails.ResourceGroup,
                PairName      = azureDetails.PairName,
                StartTime     = azureDetails.StartTime
            }),
                            "create-scheduler");

            // Fetching the name from the path parameter in the request URL
            return(req.CreateResponse(HttpStatusCode.OK, "Process Started"));
        }
        public static void Run([QueueTrigger("create-container")] string containerDetails, TraceWriter log)
        {
            var telemetry = AppInsightClient.Telemetry;

            var details = JsonConvert.DeserializeObject <ContainerDetails>(containerDetails);

            try
            {
                telemetry.TrackTrace($"Create Container: {details.ContainerName}");

                CreateContainers(details);

                AddMessage.Send(containerDetails, "retrieve-blob");
            }
            catch (Exception e)
            {
                telemetry.TrackTrace($"ERROR Container: {details.ContainerName}, Exception: {e}");
            }
        }
Exemplo n.º 3
0
        public static void Run([QueueTrigger("retrieve-blob")] string containerDetails, TraceWriter log)
        {
            var telemetry = AppInsightClient.Telemetry;

            var details = JsonConvert.DeserializeObject <ContainerDetails>(containerDetails);

            try
            {
                telemetry.TrackTrace($"Retrieve Blobs for Container: {details.ContainerName}");

                var blobs = RetrieveBlobs(details);

                foreach (var blobDetails in blobs)
                {
                    AddMessage.Send(blobDetails, "copy-blob");
                }
            }
            catch (Exception e)
            {
                telemetry.TrackTrace($"ERROR: Cannot retrieve blobs for container: {details.ContainerName}, exception: {e}");
            }
        }
Exemplo n.º 4
0
        public static void Run([QueueTrigger("get-containers")] string scheduledQueueItem, TraceWriter log)
        {
            var telemetry = AppInsightClient.Telemetry;

            try
            {
                telemetry.TrackTrace("Start Get-Containers");
                //deserialise the xml we get from scheduler to get the message.
                var pair = new StoragePair().Get(scheduledQueueItem);

                var messages = RetrieveContainers(pair, telemetry);

                foreach (var message in messages)
                {
                    //creates a message and sends to the create-container queue where next function will pick up
                    AddMessage.Send(message, "create-container");
                }
            }
            catch (Exception e)
            {
                telemetry.TrackTrace($"ERROR: {e}");
            }
        }