title: Azure IoTHub - FileUpload - Remove Device Name from BlobName
body: <p>I work on a solution in order to upload images from a LocalFileSystem to Azure Storage.</p>
  <p>For the moment we use a TokenSaS and a BlobClient but we would like to avoid to store locally an expiring SaSToken.</p>
  <p>In order to do this, we thought about Azure IoTHub, that allows us to replace this process.</p>
  <pre class="lang-py prettyprint-override"><code>def __upload_file_Azure_IoTHub(self,src_path:str,blob_path:str) -&gt;BlobClient:
          if os.path.exists(src_path):
              # We start by creating a blobClient from AzureIoTHub
              storage_info=self.IoTHub_client.get_storage_info_for_blob(blob_path)
              # We create the SAS Url from Client + Token
              sas_url=&quot;https://{}/{}/{}{}&quot;.format(
                  storage_info[&quot;hostName&quot;],
                  storage_info[&quot;containerName&quot;],
                  storage_info['blobName'],
                  storage_info[&quot;sasToken&quot;])
              try:
                  with BlobClient.from_blob_url(sas_url) as blob_client:
                      with open(src_path, &quot;rb&quot;) as fp:
                           blob=blob_client.upload_blob(fp,overwrite=True, timeout=self.config.azure_timeout)              
                  self.IoTHub_client.notify_blob_upload_status(storage_info[&quot;correlationId&quot;], True, 200, &quot;OK: {}&quot;.format(blob_path))
                  return blob
              except Exception as ex:
                  self.IoTHub_client.notify_blob_upload_status(storage_info[&quot;correlationId&quot;], False, 403, &quot;Upload Failed&quot;)
                  raise Exception(&quot;AzureUpload_IoTHub&quot;)
  </code></pre>
  <p><a href="https://github.com/MicrosoftDocs/azure-docs/blob/main/articles/iot-hub/iot-hub-devguide-file-upload.md#device-initialize-a-file-upload" rel="nofollow noreferrer">https://github.com/MicrosoftDocs/azure-docs/blob/main/articles/iot-hub/iot-hub-devguide-file-upload.md#device-initialize-a-file-upload</a></p>
  <p>The problem is that when we upload this way, the device name is added as a prefix to the blobName.
  It is a problem because it will cause us problems of rectrocompatibility :</p>
  <ul>
  <li>We defined a naming convention in our storage and this behavior will break everything.</li>
  </ul>
  <p>Let's imagine :</p>
  <pre><code>DeviceName = FileWatcherDaemon
  BlobPath   = YYYY/MM/DD/MyBlob.whatever
  # Then :
  BlobName = FileWatcherDaemon/YYYY/MM/DD/MyBlob.whatever
  # Instead of :
  BlobName = YYYY/MM/DD/MyBlob.whatever
  </code></pre>
  <p>I tried replacing the blobName by my blob_path, but it is not working because the generated sasToken is <em>blobLevel</em> and not <em>containerLevel</em>.</p>
  <p>Do you have an idea about how to remove this device name ?</p>
  <p>For us it is a problem because we will have many different devices uploading in the same storage. We would like the naming convention to fit with our business needs and not to technical information.</p>