Step 1: Local Setup¶
Prepare your development environment and Azure resources for .NET development.
Prerequisites¶
- .NET 6+ SDK: Ensure the latest SDK is installed.
- Azure CLI: For resource management.
- Visual Studio or VS Code: Recommended IDEs.
1. Create ACS Resource¶
Use the Azure CLI to create a resource:
az communication create --name "MyACSResource" --location "Global" --data-location "United States" --resource-group "MyResourceGroup"
Copy the Connection String from the output or the Azure Portal.
2. Initialize .NET Console App¶
Create a new console application:
3. Add NuGet Packages¶
Add the Identity SDK to get started:
4. Set Up User Secrets¶
For local development, use User Secrets to store your connection string securely.
dotnet user-secrets init
dotnet user-secrets set "CommunicationServices:ConnectionString" "<your-connection-string>"
5. Verify Setup¶
Update Program.cs to verify connectivity:
using Azure.Communication.Identity;
using Microsoft.Extensions.Configuration;
var config = new ConfigurationBuilder().AddUserSecrets<Program>().Build();
string connectionString = config["CommunicationServices:ConnectionString"];
if (string.IsNullOrEmpty(connectionString))
{
Console.WriteLine("Connection string not found in user secrets.");
return;
}
var client = new CommunicationIdentityClient(connectionString);
var user = await client.CreateUserAsync();
Console.WriteLine($"Successfully created user with ID: {user.Value.Id}");
Run the application:
Next Step¶
Now that your environment is ready, let's Send an SMS.