使用DevOps发布管道的带有Azure Key Vault的Docker Https

时间:2020-08-27 23:53:14

标签: azure docker https azure-devops azure-keyvault

背景:

我正在通过正常的应用程序服务计划提供身份验证服务器,并切换为将身份验证服务器用作docker容器。我将CI与dockerfile和azure-pipelines.yaml一起使用,以将映像推送到注册表。这将触发我的CD,该CD将使用Azure Web App on Container Deploy任务进行部署。在我尝试针对Authorize属性验证api之前,一切似乎都还不错。看来,即使我使用的是启用了https的自定义域。生成的令牌仍引用http而不是https。

为了避免这种情况,我尝试添加一个配置文件或“ docker-compose.yaml”。但是,当我这样做时,我的应用程序坏了。所以我的两个问题是:

-我是否可以正确运行此命令以在docker实例中使用Https?

-另外,我如何适当地将密钥库的机密传递给docker compose?

这是我的Yaml:

version: '3.4'
variables:
    - group: VKVAPI
services:
    webapp:
        image: vkv.azurecr.io/vkvauth:latest
        ports:
            - '8000:80'
            - '8001:443'
        environment:
            - ASPNETCORE_HTTPS_PORT=443
            - 'ASPNETCORE_URLS=https://+;http://+'
            - ASPNETCORE_Kestrel__Certificates__Default__Password=Variable!@#
            - ASPNETCORE_Kestrel__Certificates__Default__Path=$(variable)

也在我的日志流中,我得到了:

2020-08-27T23:14:29.758256402Z: [ERROR]  Unhandled exception. Interop+Crypto+OpenSslCryptographicException: error:2006D080:BIO routines:BIO_new_file:no such file
2020-08-27T23:14:29.758271702Z: [ERROR]     at Interop.Crypto.CheckValidOpenSslHandle(SafeHandle handle)
2020-08-27T23:14:29.758398002Z: [ERROR]     at Internal.Cryptography.Pal.OpenSslX509CertificateReader.FromFile(String fileName, SafePasswordHandle password, X509KeyStorageFlags keyStorageFlags)
2020-08-27T23:14:29.758404102Z: [ERROR]     at System.Security.Cryptography.X509Certificates.X509Certificate..ctor(String fileName, String password, X509KeyStorageFlags keyStorageFlags)
2020-08-27T23:14:29.758408302Z: [ERROR]     at System.Security.Cryptography.X509Certificates.X509Certificate2..ctor(String fileName, String password)
2020-08-27T23:14:29.758412302Z: [ERROR]     at Microsoft.AspNetCore.Server.Kestrel.KestrelConfigurationLoader.LoadCertificate(CertificateConfig certInfo, String endpointName)

1 个答案:

答案 0 :(得分:0)

我可以正确运行此命令以在Docker实例中使用Https吗?

通过docker-compose使用HTTPS运行docker容器没有问题。查看详细信息Starting a container with https support using docker-compose

此外,我如何适当地将密钥库密钥传递给docker compose?

引起错误的可能原因是Azure Web App容器中受支持的Docker Compose options不包含variables。因此,当您设置变量块并在其中使用变量时,就会导致错误。我建议您使用不带变量的绝对值。