title: Consuming a Python made Azure web service in Python
body: <p>I'm having an issue consuming Microsoft Azure web services in Python when the web service was published from Python first. I have created a web service using only Azure, then consumed that web service from Python successfully using the sample Python code from the Batch Execution API Help page. However, I also wanted to attempt to build and train my machine learning model in Python, then publish the web service to Azure. After publishing the web service to Azure, I was hoping to be able to call it again from Python in order to predict new data sets. </p>
  
  <p>I was able to train a model in Python, then successfully publish this as a web service in Azure. When I try to consume this web service in Azure though, I'm getting this error:</p>
  
  <p>The request failed with status code: 401</p>
  
  <p>{u'error': {u'message': u'Request is unauthorized to access resource.', u'code': u'Unauthorized', u'details': [{u'message': u'Invalid credentials provided.', u'code': u'ScoreRequestUnauthorized'}]}}</p>
  
  <p>I'm not sure if anyone has experience with this, and if calling a web service created in Python is different than calling a web service created in Azure. I was assuming the only things in the Batch Execution code that would be different between the web services would be the Web API key and the URL, since I'm using the same storage account. I can't see where my keys may be invalid. </p>
  
  <p>I did see you can call the service back in the same session to predict data like this:</p>
  
  <pre><code># set up web service
  @services.publish(workspace_id,authorization_token)
  @services.types(feature1=float, feature2=float)
  @services.returns(float)
  def demo(feature1,feature2):
  
      feature_vector = [feature1,feature2]
  
      return clf2.predict(feature_vector)
  
  # call published service and input new data 
  demo.service(feature1,feature2)
  </code></pre>
  
  <p>However, I don't want to retrain the model and create a new web service every time I run the code, I wanted the option to retrain the model and predict, or just predict the new data without training a new model, but I'm not sure how to consume the Python published web service without the call to the web service being in the same session.</p>
  
  <p>Thanks in advance!</p>