Search code examples
azuresmsazure-communication-services

Azure Communication Services Simple SMS


New to ACS and I simply want to send a SMS message. The official MS example doesn't work. I get a 401 unauthorized error. I have tried to build the client with connection string just like the example and I've tried using the DefaultAzureCredential. Going that direction it causes an unknown error. Does anyone have any advice how to get the ACS SMS SendAsync call to work or let me know what I am doing wrong?


Solution

  • Make sure that the <from-phone-number> is set to a phone number that you've registered earlier with the phone number capability sms:PhoneNumberCapabilityType.Outbound.

    var capabilities = new PhoneNumberCapabilities(sms:PhoneNumberCapabilityType.Outbound);
    
    // ... register the phone number and use it in the following code:
    
    SmsSendResult sendResult = smsClient.Send(
        from: "<from-phone-number>",
        to: "<to-phone-number>",
        message: "Hello World via SMS"
    );