Initializing a new project (azd init)
Downloading template code to: <your-local-path>
(✓) Done: Initialized git repository
Enter a new environment name: <your-env-name>
SUCCESS: New project initialized!
You can view the template code in your directory: <your-local-path>
Learn more about running 3rd party code on our DevHub: https://aka.ms/azd-third-party-code-notice
SUCCESS: Your application was provisioned in Azure in xx minutes xx seconds.
You can view the resources created under the resource group rg-<your-environment-name> in Azure Portal:
https://portal.azure.cn/#@/resource/subscriptions/<your-subscription-id>/resourceGroups/rg-<your-environment-name>/overview
选择子模块进行配置(以逗号分隔的输入数字,例如 [1-2,4,6],按 Enter 可全选):按 Enter 选择全部。
OAuth2 登录:根据 OAuth2 协议授权登录到 Azure。
选择订阅:选择所创建的 Azure Spring Apps 实例的订阅列表编号,它默认为列表中的第一个订阅。 如果使用默认编号,请直接按 Enter。
选择要部署的 Azure Spring Apps:选择所创建的 Azure Spring Apps 实例的列表编号。 如果使用默认编号,请直接按 Enter。
选择要公开公共访问权限的应用:(以逗号分隔的输入数字,例如 [1-2,4,6],按 Enter 可全选:输入 1,5 表示 admin-server 和 api-gateway。
确认保存上述所有配置 (Y/n):按 y。 如果按 n,则配置不会保存在 POM 文件中。
使用以下命令生成并部署每个应用程序:
./mvnw azure-spring-apps:deploy
对于“OAuth2 登录”提示,请根据 OAuth2 协议授权登录到 Azure。
注意
部署到 Azure Spring Apps 最多可能需要 25 分钟。
运行命令后,日志会显示与下例类似的输出,该输出指示所有部署均成功:
[INFO] Deployment(default) is successfully updated.
[INFO] Deployment Status: Running
[INFO] InstanceName:admin-server-default-xx-xx-xxx Status:Running Reason:null DiscoverStatus:UP
[INFO] Getting public url of app(admin-server)...
[INFO] Application url: https://<your-Azure-Spring-Apps-instance-name>-admin-server.microservices.azure.cn
...
[INFO] Getting public url of app(api-gateway)...
[INFO] Application url: https://<your-Azure-Spring-Apps-instance-name>-api-gateway.microservices.azure.cn
按照以下步骤打包应用,预配 Web 应用程序所需的 Azure 资源,然后部署到 Azure Spring Apps:
使用以下命令打包应用程序的可部署副本:
azd package
控制台输出类似于以下示例的消息:
SUCCESS: Your application was packaged for Azure in xx minutes xx seconds.
使用以下命令将应用程序代码部署到这些新预配的资源:
azd deploy
控制台输出类似于以下示例的消息:
Deploying services (azd deploy)
(✓) Done: Deploying service admin-server
- Endpoint: https://<your-Azure-Spring-Apps-instance-name>-admin-server.microservices.azure.cn
(✓) Done: Deploying service api-gateway
- Endpoint: https://<your-Azure-Spring-Apps-instance-name>-api-gateway.microservices.azure.cn
(✓) Done: Deploying service customers-service
- No endpoints were found
(✓) Done: Deploying service vets-service
- No endpoints were found
(✓) Done: Deploying service visits-service
- No endpoints were found
SUCCESS: Your application was deployed to Azure in xx minutes xx seconds.
You can view the resources created under the resource group rg-<your-environment-name> in Azure Portal:
https://portal.azure.cn/#@/resource/subscriptions/<your-subscription-id>/resourceGroups/rg-<your-environment-name>/overview