azure docker

2025919

16:02

    还是用docker部署,这个问题在一些云平台上比较常见,即 Python 解释器的版本和底层系统库的版本不匹配。

    1. 安装Azure cli,在命令行中使用az login登录(az login 会出现错误,Authentication failed against tenant <-guid-> ‘Default Directory’: (pii). Status: Response_Status.Status_InteractionRequired, Error code: 3399614476, Tag: 557973645,此时用az login --use-device-code这个命令
    2. 网页端创建容器注册表,可以推送多个docker image到一个azure容器注册表中。容器需要image来运行。假设创建的窗口注册表名称是langgraphagent。
    3. 最好是先启动Docker desktop。
    4. docker login llmappexpregistry.azurecr.io --username yourusername --password yourpassword(可能 要开代理)。
      注意:这里的用户名和密码不是微软账号和密码。使用az acr login --name langgraphagent(可能要开代理),使用的是 Azure CLI 的认证令牌,登录到langgraphagent这个容器上,然后az acr update -n langgraphagent --admin-enabled true,再运行az acr credential show --name langgraphagent --query username -o tsv获得用户名,再运行az acr credential show --name langgraphagent --query passwords[0].value -o tsv获得密码,再
      docker login langgraphagent.azurecr.io -u <上一步获取的用户名> -p <上一步获取的密码>
    5. (如果直接docker build报错)docker pull original_image_name(挂梯子,有的梯子可能也不好用,,已经pull了可以跳过) original_image_name,就是项目根目录下dockerfile文件中的第一行FROM python:3.12.3-slim中的python:3.12.3-slim
    6. (build 之前检查 dockfile)docker build -t langgraphagent.azurecr.io/botapp:v1 .(挂梯子,有的梯子可能也不好用)
    7. docker push langgraphagent.azurecr.io/botapp:v1(不用梯子)
    8. 不要第3-第7步,
      使用az acr login --name langgraphagent(可能要开代理),使用的是 Azure CLI 的认证令牌,登录到langgraphagent这个容器上,然后
      az acr build --resource-group llmappexpresourcegroup --registry langgraphagent --image agentapp:latest .
      这样在本地连docker都不需要安装 了。
    9. 新建azure app service,在容器选项卡中选择刚才上传的容器即可。
    10. app service网页端设置llm api key

 

已使用 OneNote 创建。