Yazan Kassam, DevOps Engineer
7 min read
.
July 15, 2024
Cloud computing is an integral ground for AI initiatives to reach their full potential. They offer scalable infrastructure, computational power, storage, and speed for machine learning algorithms to evolve.
An increasing number of technology enterprises are using cloud computing services in one form or another. But, as businesses change course, they may want to migrate their applications from one cloud platform to another. The reasons can include a desire for cost savings, enhanced performance, improved scalability, or leveraging unique Azure features.
In this article, we explore how AlphaApps successfully migrated an AI product from AWS to Azure. We will delve into the CI/CD challenges encountered during the migration, the innovative solutions implemented, and the resulting benefits. Additionally, we will share best practices for ensuring a smooth and efficient transition. Whether you are currently facing similar obstacles or planning a future migration, this article offers valuable insights to support your journey.
Our AI product, Pedant, is a platform that revolutionises financial document management by streamlining processes for invoices, delivery notes, and bank cheques. Leveraging artificial intelligence, Pedant automates the extraction, classification, and verification of data from these documents, helping organisations reduce operational costs, speed up processing times, and minimise errors.
Initially, we utilised AWS CodeCommit, CodeBuild, and CodePipeline for Pedant's CI/CD pipeline. This setup was effective for automating our build and test processes, facilitating seamless code integration, and running extensive tests. However, the need for enhanced integration and scalability prompted us to migrate to Azure.
Let us delve into the specific reasons behind this decision and the benefits we aimed to achieve.
Here’s why we chose to migrate our AI product to Azure.
Azure offers several AI tools and services under its Cognitive Services suite, each tailored for specific applications. For an AI product focused on intelligent document processing like ours, services like Azure AI Vision and Azure Form Recognizer are invaluable. These tools automate and enhance data extraction, classification, and verification processes. They also significantly improve efficiency and accuracy in managing financial documents such as invoices, delivery notes, and bank cheques.
The integration with OpenAI in Azure OpenAI Service provides REST API access to OpenAI's powerful language models, including GPT-4 and GPT-4o. This allows AI products to leverage the advanced capabilities of GPT-4 without needing to set up separate infrastructure or manage deployments.
The architecture of Azure Web App offers high flexibility and efficiency in resource consumption with Scale out and Scale up features, especially compared to AWS Lambda Functions, which have a memory limit of 10,240 MB. For AI products and services, this means more scalable and adaptable resource management, enabling complex and demanding applications.
Additionally, Azure Web App Plans allow shared computing resources among multiple apps. They enhance cost management and make it easier to scale AI applications without incurring prohibitive costs.
Transitioning from fully serverless AWS Lambda Functions to server-based Azure Web App has been crucial for cost management. The approach is particularly beneficial when handling a high volume of document processing requests, as it allows for more manageable resource allocation. The server-based architecture in Azure ensures that AI projects can maintain high performance and scalability while optimising operational expenses.
Pedant was our first product on Azure and it required us to get familiar with a new cloud platform. We dedicated time to learning and adapting to Azure’s environment, ensuring a smooth transition and effective use of its services. Our efforts laid a solid foundation for successfully implementing Pedant and leveraging Azure's capabilities for optimal performance.
Azure offers several managed computing services, including Container Instance, Web App, Container App, Function, and AKS. Selecting the best option for each microservice in our project posed a significant challenge. To address this, we conducted thorough evaluations of each service and focused on their specific functionalities and capabilities.
Transitioning Pedant's AI section from serverless computing to server-based services was essential to achieve stability. This shift allowed us to overcome the capacity limitations inherent in serverless computing. It ensured that Pedant could scale seamlessly with growing demand. By adopting server-based services, we enhanced the platform's ability to handle intensive document processing tasks efficiently.
Initially, Azure Web App presented a challenge as it did not support running multiple containers simultaneously for deployment, especially when including sidecar containers. However, Azure introduced Docker Compose as a preview feature to support this function.
Following extensive testing and quality assurance, we found it to be stable and well-suited for our production environment. This update resolved our initial deployment limitations and provided flexibility.
Azure Container App did not support exposing multiple ports for HTTP/gRPC from our containers, which posed a challenge for our application's functionality. However, a recent production release introduced this feature, effectively resolving the limitation. This update enhanced our app's capabilities by allowing us to manage multi-port exposures seamlessly.
Azure Container App offers a consumption plan based on request volume that proved cost-effective for our application. It effectively aligns our operational costs with actual usage demands. This approach minimised overhead expenses while ensuring optimal resource utilisation, helping with project efficiency and budget management.
Azure Container App also supports stickiness for WebSocket connections and features a scale to zero capability. It optimises resource usage by scaling down to zero instances during periods of inactivity.
Embracing MLOps in Azure Machine Learning has streamlined our model training and deployment processes. MLOps tools in Azure Machine Learning ensure smoother operations and more effective deployment of AI solutions, driving overall product success and innovation.
Maximise cost efficiency by aligning resource utilisation with the specific needs of your product at each development stage. For instance, to cut expenses, we utilised Azure Functions with zip deployment instead of a dockerized approach. This allowed us to take advantage of the 'pay as you go' pricing model instead of the more costly Premium tier.
Additionally, employ a strategic migration assessment tool to evaluate your readiness for migrating an AI product. This ensures smooth operation post-migration and helps you achieve your goals. Keep stakeholders informed and involved early in the process to secure their support and facilitate a seamless transition.
Implement CI/CD tools that integrate seamlessly with your existing repositories. Given our repositories were already on GitLab, we opted for GitLab CI to facilitate rapid deployment. To address the disk space issue, we implemented a GitLab Custom Runner on an Azure VM, which provided the necessary capacity for building our AI images.
By Dockerizing all AI services and abandoning all AWS SDKs and Lambda's libraries, organisations undoubtedly expedite the migration process to Azure effectively.
Develop a data migration carefully to ensure compatibility. The command-line utility AzCopy can be used to copy unstructured files such as PDFs and images to and from a storage account. It is an invaluable tool for seamless data movement from an EC2 Jumpbox to Azure Storage Account Containers.
Containerising your AI applications with Docker and deploying them on Azure Kubernetes Service (AKS) can make your applications more scalable, portable, and manageable. It helps streamline deployment and ensures your AI solution runs smoothly across different environments.
In conclusion, the migration of our AI product from AWS to Azure posed numerous challenges, yet with careful planning, we were able to overcome them and enhance our CI/CD process. This experience has offered us valuable insights that will shape our future AI strategies.
The transition to Azure has equipped us with powerful tools such as Azure Document Intelligence and Azure AI Version, improving the accuracy of OCR processing and field extraction from invoices and cheques.
Organisations looking to migrate AI products to Azure should adopt a strategic approach, leveraging cloud-native tools like MLOps in Azure Machine Learning to enhance current products and pave the way for more agile and scalable AI solutions.
Migrating an AI product from AWS to Azure involves challenges such as service compatibility, data transfer complexities, adapting to Azure tools, integrating existing infrastructure, and cost management through continuous monitoring and adjustment.
Switching from AWS to Azure requires adapting to Azure-specific tools, services, and infrastructure, which may be challenging initially. However, with thorough planning and understanding of Azure's offerings, the transition can be managed effectively to align with organisational goals and requirements.