Windows 10 Mobile 10.0.10586.63 No Cellular Data (AT&T)

I like to think of myself as pretty open minded when it comes to technology. While I do spend 70% of my time on the Microsoft stack in the .NET realm, I do spend a lot of time in other areas as well. I have both a MacBook Pro and a Surface and I do quite a bit of mobile development on iOS with Obj-C and Swift, little Android, and some Windows Mobile. I have owned all of the major phone platforms at one point or another but most recently went back to a Windows Phone. I know what your thinking, why would I do that. I really like the idea of a third player out there to round things out and frankly I was getting a little bored with the iPhone after four years of pretty much the same interface and functionality. So I got me a Windows Phone and jumped right in with the Windows Insider Program.  I have actually really been enjoying the Windows 10 Mobile platform and I am a big fan of Windows 10 in general.  Things have been great until this weekend when 10.0.10586.63 got rolled out to the insiders.  My first thought was, “excellent, can’t wait to see all of the enhancements”.  The install went fine and things were looking good until I left my home for the first time only to realize I no longer had cellular data connection and couldn’t send MMS messages.  Every application said “Sorry, no network connectivity”.  I was enraged because yesterday things were close to perfect before the upgrade.  Well, after threating to go back to my iPhone, calming down a little and remembering I did sign up for a beta program on my main device, I did some research. I was able to get the cellular data working again.  The “Force” has been restored.  Here are the steps and settings I used to get my data back on.

Settings -> Network & Wireless -> Cellular & SIM

  • Make sure Cellular data in turned on
  • Click on “SIM Settings”
  • Add an Internet APN (making sure to save)
    wp_ss_20160130_0001 wp_ss_20160130_0002
  • Add an MMS APN (making sure to save)
    wp_ss_20160130_0003 wp_ss_20160130_0004

Hope this helps a few of you out and keeps you loving the Windows 10 Mobile OS.

 

403 forbidden when calling Azure Service Management REST api from a worker role instance

So a couple of weeks ago I blogged about how to make use of the Service Bus Entity Metrics REST APIs and some of the things I learned. The next step of the puzzle was to create a worker role that would monitor some of my service bus queues using this API and logs the results.  A team member and I started down the path of creating this worker and thought things were going great.  We installed the certificate on our local machine that we uploaded to the Azure portal and ran the worker locally thru the emulator and all worked well.  Unfortunately, that’s were the celebration stopped.  Once we deployed the worker to a cloud service instance, we kept getting a 403 forbidden exception when the worker tried to call the management API.  After days of fighting this, we finally had success.  Here are the steps we took to make this successful.

  • First things first you need to create a self-signed certificate.  This is the really specific piece.  There are lots of articles on doing this but they all seemed to lack one specific detail.  Credit for these steps clearly go to Jeff and his post on stack overflow.  Run these two commands to create your certificate files.
    makecert -r -pe -n "CN=[name of certificate]" -sky exchange "[path to certificate].cer" -sv "[path to certificate].pvk"
    pvk2pfx -pvk "[path to certificate].pvk" -spc "[path to certificate].cer" -pfx "[path to certificate].pfx" -pi [password]
    
  • Upload the .cer file to the Azure Portal. This is at the subscription level
    azure portal certificate
  • Upload the .pfx file to the cloud service instance hosting your worker role
    cloud service certificate
  • Inside Visual Studio, add the certificate to the Worker Role properties
    worker properties
  • We actually wrote a small custom web client to abstract some of the details.
        public class AzureManagementWebClient : WebClient
        {
            string _thumbprint = CloudConfig.Get("ServiceBusAPICertificateThumb");
    
            protected override WebRequest GetWebRequest(Uri address)
            {
                var request = base.GetWebRequest(address);
    
                //The certificate must be installed on your local machine and configured to deploy with worker
                var certs = this.GetCertificate(StoreLocation.CurrentUser);
                if (certs.Count == 0)
                {
                    certs = this.GetCertificate(StoreLocation.LocalMachine);
                }
                if (certs.Count == 0)
                {
                    throw new ArgumentNullException(string.Format("Certificate: {0}", _thumbprint));
                }
    
    
                (request as HttpWebRequest).ClientCertificates.Add(certs[0]);
                (request as HttpWebRequest).Headers.Add("x-ms-version: 2013-10-01");
                (request as HttpWebRequest).Accept = "application/json";
    
                return request;
            }
    
            private X509Certificate2Collection GetCertificate(StoreLocation location)
            {
                var store = new X509Store(StoreName.My, location);
                store.Open(OpenFlags.ReadOnly | OpenFlags.OpenExistingOnly);
                var collection = store.Certificates.Find(X509FindType.FindByThumbprint, _thumbprint, false);
                store.Close();
                return collection;
            }
    
        }
    
    
  • In order to run this locally with the emulator, you will need to import the pfx into your Local Machine / Personal certificate store 

Azure Service Bus Entity Metrics API

The other day I was presented with a project for a client wanting to add some monitoring and alerting to some of their Azure resources. Azure has some metrics and alerting functionality on most of their resources such as CPU, DTU, Memory, etc. Click here to see information related to creating these alerts. One challenge I was faced with was monitoring metrics around service bus queues.  Unfortunately, Microsoft has not provided the same monitoring and alerting functionality for service bus queues through the Azure portal.  After some research, I uncovered a REST API for retrieving metrics for service bus queues.  Problem solved, right? Not!  I spent a couple of days trying to figure out this loosely documented API.  After many searches through the web, it appears everyone is having the same problem.  The API is there but apparently no one can figure out how to use it.  Someone uncovered yet another API exposed which is completely different and I was able to get it to work.  In this link someone mentions they figured out they could use the following:

https://management.core.windows.net/%5Bsubscriberid%5D/services/monitoring/metricvalues/query?resourceId=/servicebus/namespaces/%5Bnamespace%5D/Queues/%5Bqueue%5D&names=size,incoming,outgoing,length,requests.total,requests.successful,requests.failed,requests.failed.internalservererror,requests.failed.serverbusy,requests.failed.other&timeGrain=PT5M&startTime=2015-11-16T08:59:27.7243529Z&endTime=2015-11-16T17:19:27.7243529Z

While this did work, I was not satisfied not being able to use the API that is documented above.  After more playing around, the magic sauce was finally discovered around how this API works. The following implementation worked successfully:

https://management.core.windows.net/%5Bsubscriberid%5D/services/servicebus/namespaces/%5Bnamespace%5D/queues/%5Bqueue%5D/metrics/incoming/rollups/PT1H/values?$filter=Timestamp%20gt%20datetime'2015-11-16T12:00:00.0000000Z'

There are a few very specific notes when using this API.

  • As mentioned in the Microsoft article, you will have to create a certificate and upload to the Azure management portal and then use this certificate to call the API.
  • You must send this header with the request:   x-ms-version: 2013-10-01
  • The API returns XML by default.  If you want to return JSON instead, send this header with the request:   Accept: application/json
  • If you omit the /values?$filter=Timestamp%20gt%20datetime’2015-11-16T12:00:00.0000000Z’ from your request, you will simply get metrics back but all of the values will return null.
  • The format of the filter is very specific. The “Timestamp” property is case sensitive.  If you pass it lower case you will receive a HTTP 500 error.
  • The Rollup options PT5M, PT1H, P1D, P7D must be all upper case

I created a custom WebClient that encapsulates the details of the headers and certificates.

class AzureManagementClient : WebClient
{
    protected override WebRequest GetWebRequest(Uri address)
    {
        var request = (HttpWebRequest)base.GetWebRequest(address);

        X509Store store = new X509Store("My", StoreLocation.CurrentUser);
        store.Open(OpenFlags.ReadOnly);
        X509Certificate2Collection certificates = store.Certificates.Find(X509FindType.FindBySubjectName, "[certificate name]", false);
        var cert = certificates[0];

        request.ClientCertificates.Add(cert);
        request.Headers.Add("x-ms-version: 2013-10-01");
        request.Accept = "application/json";
        
        return request;
    }
}

blog_spacer