Creating an App with MSDN App Services
This guide will walk you through the process of creating a new application using MSDN App Services. We'll cover the essential steps from initial setup to your first deployment.
Prerequisites
Before you begin, ensure you have the following:
- A Microsoft Account.
- The MSDN SDK installed (version 2.5 or later).
- An active internet connection.
Step-by-Step Guide
Step 1: Initialize Your Project
Navigate to your project directory in the terminal and initialize a new app service project using the MSDN CLI:
msdn app create my-new-app --template basic
This command creates a new application named my-new-app using the basic template.
Step 2: Configure Your App Settings
Open the appsettings.json file in your project's root directory. Here, you can configure various aspects of your application, such as:
- Database connection strings.
- API keys for third-party services.
- Environment-specific configurations.
Here's an example configuration:
{
"Database": {
"ConnectionString": "Server=your_server;Database=your_db;User Id=your_user;Password=your_password;"
},
"ApiKeys": {
"ExternalService": "your_api_key_here"
}
}
Step 3: Define Your App Logic
The core of your application resides in the src/controllers and src/services directories. Create your API endpoints and business logic here.
For example, a simple API endpoint in src/controllers/helloController.js:
// src/controllers/helloController.js
import { Controller, Get } from '@msdn/app-services';
@Controller('/hello')
export class HelloController {
@Get('/')
getGreeting() {
return { message: 'Hello from MSDN App Services!' };
}
}
Step 4: Register Dependencies
If your application uses custom services or components, register them in the src/app.js file using the dependency injection container.
// src/app.js
import { App } from '@msdn/app-services';
import { HelloController } from './controllers/helloController';
import { MyCustomService } from './services/myCustomService';
const app = new App();
app.register(HelloController);
app.register(MyCustomService); // If you have a custom service
export default app;
Step 5: Build and Deploy
Once your application logic is in place, build your project and deploy it to the MSDN App Services platform.
To build:
msdn app build
To deploy:
msdn app deploy production
Replace production with your desired deployment environment.
Next Steps
Congratulations! You've successfully created and deployed your first app with MSDN App Services. Here are some resources for further exploration:
Continue to Managing Users