Ejemplo n.º 1
0
        public override async Task WriteSnapshotAsync(ScriptSecretsType type, string functionName, ScriptSecrets secrets)
        {
            if (secrets == null)
            {
                throw new ArgumentNullException(nameof(secrets));
            }

            string blobPath = GetSecretsBlobPath(type, functionName);

            blobPath = SecretsUtility.GetNonDecryptableName(blobPath);
            await WriteToBlobAsync(blobPath, ScriptSecretSerializer.SerializeSecrets(secrets));
        }
Ejemplo n.º 2
0
        public override async Task WriteAsync(ScriptSecretsType type, string functionName, ScriptSecrets secrets)
        {
            if (secrets == null)
            {
                throw new ArgumentNullException(nameof(secrets));
            }

            string blobPath = GetSecretsBlobPath(type, functionName);

            await WriteToBlobAsync(blobPath, ScriptSecretSerializer.SerializeSecrets(secrets));

            string filePath = GetSecretsSentinelFilePath(type, functionName);
            await FileUtility.WriteAsync(filePath, DateTime.UtcNow.ToString());
        }
Ejemplo n.º 3
0
        public override async Task WriteSnapshotAsync(ScriptSecretsType type, string functionName, ScriptSecrets secrets)
        {
            ArgumentNullException.ThrowIfNull(secrets);

            string blobPath = GetSecretsBlobPath(type, functionName);

            blobPath = SecretsUtility.GetNonDecryptableName(blobPath);

            try
            {
                await WriteToBlobAsync(blobPath, ScriptSecretSerializer.SerializeSecrets(secrets));
            }
            catch (Exception ex)
            {
                LogErrorMessage("write", ex);
                throw;
            }
        }
Ejemplo n.º 4
0
        public override async Task WriteAsync(ScriptSecretsType type, string functionName, ScriptSecrets secrets)
        {
            ArgumentNullException.ThrowIfNull(secrets);

            string blobPath = GetSecretsBlobPath(type, functionName);

            try
            {
                await WriteToBlobAsync(blobPath, ScriptSecretSerializer.SerializeSecrets(secrets));
            }
            catch (Exception ex)
            {
                LogErrorMessage("write", ex);
                throw;
            }

            string filePath = GetSecretsSentinelFilePath(type, functionName);
            await FileUtility.WriteAsync(filePath, DateTime.UtcNow.ToString());
        }
        private static bool TryLoadSecrets(string filePath, Func <string, ScriptSecrets> deserializationHandler, out ScriptSecrets secrets)
        {
            secrets = null;

            if (File.Exists(filePath))
            {
                // load the secrets file
                string secretsJson = File.ReadAllText(filePath);
                secrets = deserializationHandler(secretsJson);
            }

            return(secrets != null);
        }
 private static bool TryLoadSecrets(ScriptSecretsType secretsType, string filePath, out ScriptSecrets secrets)
 => TryLoadSecrets(filePath, s => ScriptSecretSerializer.DeserializeSecrets(secretsType, s), out secrets);