Warning: client only. Use REST API from backend deployed on Azure Spring Cloud spring-petclinic-rest project. Following steps need to be done before deploying this project
- You need to deploy Spring petclinic rest project on Azure Spring Cloud and assign a public end point.
- Copy the Assigned end point and modify the code in environment.ts and environment.prod.ts for production deploy.
git clone https://github.com/selvasingh/spring-petclinic-angular.git
cd spring-petclinic-angular
git checkout azure
ng build
Run ng build
to build the project. The build artifacts will be stored in the dist/
directory. Use the -prod
flag for a production build.
You can also build the application in a dedicated docker image using the provided Dockerfile
as follows:
docker build -t spring-petclinic-angular:latest .
Then you will be able to use it as follows:
docker run --rm -p 1025:1025 spring-petclinic-angular:latest
After running the docker client locally the application should be able to hit the exposed rest end point of the Spring Petclinic Rest project
- Install docker
- Open a shell and cd to the same directory as this README.
- Export a variable with your registry name:
export REGISTRY=myregistry
- Run the following Docker commands to build, tag, and publish the image from the
httpapi
directory:
docker build -t spring-petclinic-angular -f Dockerfile .
docker tag spring-petclinic-angular $REGISTRY/spring-petclinic-angular:latest
docker push $REGISTRY/spring-petclinic-angular:latest
After building and testing locally with the Dockerfile, you can now deploy the application to Azure Spring Cloud service. Following are the steps needed to deploy to Azure Spring Cloud.
Install the Azure CLI to run CLI reference commands.
-
If you're using a local installation, sign in to the Azure CLI by using the az login command. To finish the authentication process, follow the steps displayed in your terminal. For additional sign-in options, see Sign in with the Azure CLI.
-
Run az version to find the version and dependent libraries that are installed. To upgrade to the latest version, run az upgrade.
Install the Azure Spring Cloud extension
Before installing the Azure Spring Cloud CLI extension, please ensure that an older verison of the extension is not installed:
az extension remove -n spring-cloud
Install the latest version of the extension with the following command:
az extension add -n spring-cloud
For more information about extensions, see Use extensions with the Azure CLI.
Follow Create Azure Spring Cloud service instance to create an Azure Spring Cloud service instance.
Create a microservice app.
az spring-cloud app create --name spring-petclinic-angular --instance-count 1 --assign-endpoint true
Deploy Spring Petclinic Angular application to Azure.
Important Note: Application must expose 1025 port for Azure Spring Cloud health probing. Check How does Azure Spring Cloud monitor the health status of my application? for details.
az spring-cloud app deploy --name spring-petclinic-angular --container-image spring-petclinic-angular:latest --container-registry $REGISTRY
or (for the private registry)
az spring-cloud app deploy --name spring-petclinic-angular --container-image spring-petclinic-angular:latest --container-registry $REGISTRY --registry-username $USERNAME --registry-password $PASSWORD
And please check Customize container for Azure Spring Cloud for the full CLI commands list.
Congratulations! You've successfully deployed Spring Petclinic Angular to Azure Spring Cloud.