internal async Task <SemVersion> GetDeployedRuntimeVersion(InstanceName instance, IAzure azure, CancellationToken cancellationToken)
        {
            logger.WriteVerbose($"Retrieving functions runtime from {instance.PlainName} app");
            SemVersion uploadedRuntimeVer;
            var        kudu = new KuduApi(instance, azure, logger);

            using (var client = new HttpClient())
                using (var request = await kudu.GetRequestAsync(HttpMethod.Get, $"api/vfs/site/wwwroot/aggregator-manifest.ini", cancellationToken))
                    using (var response = await client.SendAsync(request, cancellationToken))
                    {
                        string manifest = await response.Content.ReadAsStringAsync();

                        if (response.IsSuccessStatusCode)
                        {
                            uploadedRuntimeVer = ManifestParser.Parse(manifest).Version;
                        }
                        else
                        {
                            logger.WriteWarning($"Cannot read aggregator-manifest.ini: {response.ReasonPhrase} (disregard this message on new instances)");
                            uploadedRuntimeVer = new SemVersion(0, 0, 0);
                        }
                    }

            logger.WriteVerbose($"Function Runtime version is {uploadedRuntimeVer}.");
            return(uploadedRuntimeVer);
        }
Esempio n. 2
0
        private async Task <SemVersion> GetLocalPackageVersionAsync(string runtimePackageFile)
        {
            if (File.Exists(runtimePackageFile))
            {
                var zip           = ZipFile.OpenRead(runtimePackageFile);
                var manifestEntry = zip.GetEntry("aggregator-manifest.ini");
                using (var byteStream = manifestEntry.Open())
                    using (var reader = new StreamReader(byteStream))
                    {
                        var content = await reader.ReadToEndAsync();

                        var info = ManifestParser.Parse(content);
                        return(info.Version);
                    }
            }

            // this default allows SemVer to parse and compare
            return(new SemVersion(0, 0));
        }
Esempio n. 3
0
        private async Task <SemVersion> GetLocalPackageVersionAsync(string runtimePackageFile)
        {
            if (!File.Exists(runtimePackageFile))
            {
                // this default allows SemVer to parse and compare
                return(new SemVersion(0, 0));
            }

            using (var zip = ZipFile.OpenRead(runtimePackageFile))
            {
                var manifestEntry = zip.GetEntry("aggregator-manifest.ini");
#pragma warning disable S5042                                                                // Make sure that decompressing this archive file is safe
                using (var byteStream = manifestEntry.Open())
                                                               #pragma warning restore S5042 // Make sure that decompressing this archive file is safe
                    using (var reader = new StreamReader(byteStream))
                    {
                        var content = await reader.ReadToEndAsync();

                        var info = ManifestParser.Parse(content);
                        return(info.Version);
                    }
            }
        }