![]() cd serverĬreate a new web app for the server component of the MERN application with az webapp up. If you haven't already, sign in to the Azure CLI using the az login -use-device-code command.Ĭhange the current working directory to the server/ path. # Variable for web app names with a randomnly generated suffix # Variable for randomnly generated suffix # Variable for resource group nameĬreate shell variables for the two web app named serverAppName and clientAppName. Within your integrated development environment (IDE), open a new terminal.Ĭreate a shell variable for the name of the pre-existing resource group named resourceGroupName. Use secrets in the web apps to store environment variables with credentials and API endpoints. Then, close the terminal.ĭeploy the MERN application to Azure App Serviceĭeploy the service and client to Azure App Service to prove that the application works end-to-end. The API automatically opens a browser window to verify that it returns an array of product documents.Ĭlose the extra browser tab/window. Validate that the application is using the database service by changing the context of the terminal to the server/ folder, installing dependencies from Node Package Manager (npm), and then starting the application. Use the same connection string you used with the mongo shell. The connection string to the Azure Cosmos DB for MongoDB vCore cluster. In the client/.env file, add an environment variable for this value: Environment Variable The object ids ( _id) are randomnly generated and will differ from this truncated example output. Here's a truncated example of the output. The playground run should result in a list of documents in the local MongoDB collection. Select the Run all icon to execute the script. Once the connection is successful, open the data/products.mongodb playground file. In the side bar, select the MongoDB extension.Īdd a new connection to the MongoDB extension using the connection string mongodb://localhost. docker pull mongo:6.0ĭocker run -detach -publish 27017:27017 mongo:6.0 Run a MongoDB container using Docker and publish the typical MongoDB port ( 27017). ![]() Start by running the sample application's API with the local MongoDB container to validate that the application works. Test the MERN application's API with the MongoDB container The remaining steps in this tutorial take place in the context of this development container. This tutorial requires the following versions of each tool which are preinstalled in your environment: Tool
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |