Ejemplo n.º 1
0
        public async Task SyncTriggersAsync()
        {
            var tracer = _traceFactory.GetTracer();
            using (tracer.Step("FunctionManager.SyncTriggers"))
            {
                if (!IsFunctionEnabled)
                {
                    tracer.Trace("This is not a function-enabled site!");
                    return; 
                }

                var inputs = await GetTriggerInputsAsync(tracer);
                if (inputs.Count == 0)
                {
                    tracer.Trace("No input triggers!");
                    return;
                }

                if (Environment.IsAzureEnvironment())
                {
                    var client = new OperationClient(tracer);
                    await client.PostAsync("/operations/settriggers", inputs);
                }
            }
        }
Ejemplo n.º 2
0
        public async Task SyncTriggersAsync(ITracer tracer = null)
        {
            tracer = tracer ?? _traceFactory.GetTracer();
            using (tracer.Step("FunctionManager.SyncTriggers"))
            {
                if (!IsFunctionEnabled)
                {
                    tracer.Trace("This is not a function-enabled site!");
                    return;
                }

                var jwt = System.Environment.GetEnvironmentVariable(Constants.SiteRestrictedJWT);
                if (String.IsNullOrEmpty(jwt))
                {
                    // If there is no token, do nothing. This can happen on non-dynamic stamps
                    tracer.Trace("Ignoring operation as we don't have a token");
                    return;
                }

                var inputs = await GetTriggerInputsAsync(tracer);

                if (Environment.IsAzureEnvironment())
                {
                    var client = new OperationClient(tracer);

                    await client.PostAsync("/operations/settriggers", inputs);
                }
            }
        }
Ejemplo n.º 3
0
        public async Task HandleAutoSwap(string currentDeploymetId, DeploymentContext context)
        {
            ITracer tracer = context.Tracer;

            if (!IsAutoSwapEnabled())
            {
                tracer.Trace("AutoSwap is not enabled");
                return;
            }

            string jwtToken = System.Environment.GetEnvironmentVariable(Constants.SiteRestrictedJWT);

            if (string.IsNullOrWhiteSpace(jwtToken))
            {
                tracer.Trace("Jwt token is null");
                return;
            }

            // active deployment is always a success deployment
            string lastDeploymentId = _deploymentStatusManager.ActiveDeploymentId;

            if (string.Equals(currentDeploymetId, lastDeploymentId, StringComparison.OrdinalIgnoreCase))
            {
                tracer.Trace("Deployment haven't changed, no need for auto swap: {0}", lastDeploymentId);
                return;
            }

            try
            {
                FileSystemHelpers.WriteAllTextToFile(_autoSwapLockFilePath, String.Empty);
            }
            catch (Exception ex)
            {
                tracer.TraceError(ex);
            }

            string operationId = "AUTOSWAP" + Guid.NewGuid();

            var queryStrings = HttpUtility.ParseQueryString(string.Empty);

            queryStrings["slot"]        = _autoSwapSlotName;
            queryStrings["operationId"] = operationId;

            var client = new OperationClient(context.Tracer);
            await client.PostAsync <string>("/operations/autoswap?" + queryStrings.ToString());

            context.Logger.Log("Requesting auto swap to slot - '{0}' operation id - '{1}' deployment id - '{2}'".FormatInvariant(_autoSwapSlotName, operationId, currentDeploymetId));
        }
Ejemplo n.º 4
0
        public async Task SyncTriggers()
        {
            var tracer = _traceFactory.GetTracer();

            using (tracer.Step("FunctionManager.SyncTriggers"))
            {
                if (!IsFunctionEnabled())
                {
                    tracer.Trace("This is not a function-enabled site!");
                    return;
                }

                var inputs = GetTriggerInputs(tracer);
                if (inputs.Count == 0)
                {
                    tracer.Trace("No input triggers!");
                    return;
                }

                var client = new OperationClient(tracer);
                await client.PostAsync("/operations/settriggers", inputs);
            }
        }
Ejemplo n.º 5
0
        public async Task HandleAutoSwap(string currentDeploymetId, ILogger logger, ITracer tracer)
        {
            if (!IsAutoSwapEnabled())
            {
                tracer.Trace("AutoSwap is not enabled");
                return;
            }

            string jwtToken = System.Environment.GetEnvironmentVariable(Constants.SiteRestrictedJWT);

            if (string.IsNullOrWhiteSpace(jwtToken))
            {
                tracer.Trace("Jwt token is null");
                return;
            }

            try
            {
                FileSystemHelpers.WriteAllTextToFile(_autoSwapLockFilePath, String.Empty);
            }
            catch (Exception ex)
            {
                tracer.TraceError(ex);
            }

            string operationId = "AUTOSWAP" + Guid.NewGuid();

            var queryStrings = HttpUtility.ParseQueryString(string.Empty);

            queryStrings["slot"]        = _autoSwapSlotName;
            queryStrings["operationId"] = operationId;

            var client = new OperationClient(tracer);
            await client.PostAsync <string>("/operations/autoswap?" + queryStrings.ToString());

            logger.Log("Requesting auto swap to slot - '{0}' operation id - '{1}' deployment id - '{2}'".FormatInvariant(_autoSwapSlotName, operationId, currentDeploymetId));
        }
Ejemplo n.º 6
0
        public async Task SyncTriggersAsync(ITracer tracer = null)
        {
            tracer = tracer ?? _traceFactory.GetTracer();
            using (tracer.Step("FunctionManager.SyncTriggers"))
            {
                if (!IsFunctionsSiteExtensionEnabled)
                {
                    tracer.Trace("Functions are not enabled for this site.");
                    return;
                }

                var jwt = System.Environment.GetEnvironmentVariable(Constants.SiteRestrictedJWT);
                if (String.IsNullOrEmpty(jwt))
                {
                    // If there is no token, do nothing. This can happen on non-dynamic stamps
                    tracer.Trace("Ignoring operation as we don't have a token");
                    return;
                }

                var functions = await ListFunctionsConfigAsync();

                var triggers = GetTriggers(functions, tracer);

                // This is to allow scale decisions to be made for the app if routing is enabled for a dynamic function app,
                if (IsRoutingSiteExtensionEnabled)
                {
                    triggers.Add(JToken.Parse("{\"type\":\"routingTrigger\"}"));
                }

                if (Environment.IsAzureEnvironment())
                {
                    var client = new OperationClient(tracer);
                    await client.PostAsync("/operations/settriggers", triggers);
                }
            }
        }
Ejemplo n.º 7
0
        public async Task HandleAutoSwap(string currentDeploymetId, DeploymentContext context)
        {
            ITracer tracer = context.Tracer;
            if (!IsAutoSwapEnabled())
            {

                tracer.Trace("AutoSwap is not enabled");
                return;
            }

            string jwtToken = System.Environment.GetEnvironmentVariable(Constants.SiteRestrictedJWT);
            if (string.IsNullOrWhiteSpace(jwtToken))
            {
                tracer.Trace("Jwt token is null");
                return;
            }

            // active deployment is always a success deployment
            string lastDeploymentId = _deploymentStatusManager.ActiveDeploymentId;
            if (string.Equals(currentDeploymetId, lastDeploymentId, StringComparison.OrdinalIgnoreCase))
            {
                tracer.Trace("Deployment haven't changed, no need for auto swap: {0}", lastDeploymentId);
                return;
            }

            try
            {
                FileSystemHelpers.WriteAllTextToFile(_autoSwapLockFilePath, String.Empty);
            }
            catch (Exception ex)
            {
                tracer.TraceError(ex);
            }

            string operationId = "AUTOSWAP" + Guid.NewGuid();

            var queryStrings = HttpUtility.ParseQueryString(string.Empty);
            queryStrings["slot"] = _autoSwapSlotName;
            queryStrings["operationId"] = operationId;

            var client = new OperationClient(context.Tracer);
            await client.PostAsync<string>("/operations/autoswap?" + queryStrings.ToString());
            context.Logger.Log("Requesting auto swap to slot - '{0}' operation id - '{1}' deployment id - '{2}'".FormatInvariant(_autoSwapSlotName, operationId, currentDeploymetId));
        }
Ejemplo n.º 8
-1
        public async Task SyncTriggersAsync(ITracer tracer = null)
        {
            tracer = tracer ?? _traceFactory.GetTracer();
            using (tracer.Step("FunctionManager.SyncTriggers"))
            {
                if (!IsFunctionEnabled)
                {
                    tracer.Trace("This is not a function-enabled site!");
                    return; 
                }

                var jwt = System.Environment.GetEnvironmentVariable(Constants.SiteRestrictedJWT);
                if (String.IsNullOrEmpty(jwt))
                {
                    // If there is no token, do nothing. This can happen on non-dynamic stamps
                    tracer.Trace("Ignoring operation as we don't have a token");
                    return;
                }

                var inputs = await GetTriggerInputsAsync(tracer);
                if (Environment.IsAzureEnvironment())
                {
                    var client = new OperationClient(tracer);

                    await client.PostAsync("/operations/settriggers", inputs);
                }
            }
        }
Ejemplo n.º 9
-1
        public async Task HandleAutoSwap(string currentDeploymetId, ILogger logger, ITracer tracer)
        {
            if (!IsAutoSwapEnabled())
            {

                tracer.Trace("AutoSwap is not enabled");
                return;
            }

            string jwtToken = System.Environment.GetEnvironmentVariable(Constants.SiteRestrictedJWT);
            if (string.IsNullOrWhiteSpace(jwtToken))
            {
                tracer.Trace("Jwt token is null");
                return;
            }
            
            try
            {
                FileSystemHelpers.WriteAllTextToFile(_autoSwapLockFilePath, String.Empty);
            }
            catch (Exception ex)
            {
                tracer.TraceError(ex);
            }

            string operationId = "AUTOSWAP" + Guid.NewGuid();

            var queryStrings = HttpUtility.ParseQueryString(string.Empty);
            queryStrings["slot"] = _autoSwapSlotName;
            queryStrings["operationId"] = operationId;

            var client = new OperationClient(tracer);
            await client.PostAsync<string>("/operations/autoswap?" + queryStrings.ToString());
            logger.Log("Requesting auto swap to slot - '{0}' operation id - '{1}' deployment id - '{2}'".FormatInvariant(_autoSwapSlotName, operationId, currentDeploymetId));
        }