Repository: cloud-custodian/cloud-custodian

Issue:
output to Azure blob storage doesn't store actual output
### Describe the bug

When a policy is configured to write its output to an Azure blob container, the resultant blob objects contain only a plain text string of the local output location (i.e. `/tmp/tmp<random string>/<filename>.gz`)

### What did you expect to happen?

I expected the blob objects to contain a gzipped version of the output file corresponding to the blob name. i.e.: `resources.json.gz` should contain a gzipped file in JSON format describing the resources retrieved by that policy run.

### Cloud Provider

Microsoft Azure

### Cloud Custodian version and dependency information

```shell
Please copy/paste the following info along with any bug reports:

Custodian:   0.9.30
Python:      3.11.2 (v3.11.2:878ead1ac1, Feb  7 2023, 10:02:41) [Clang 13.0.0 (clang-1300.0.29.30)]
Platform:    posix.uname_result(sysname='Darwin', nodename='F9YPT71GDJ', release='22.6.0', version='Darwin Kernel Version 22.6.0: Wed Jul  5 22:22:05 PDT 2023; root:xnu-8796.141.3~6/RELEASE_ARM64_T6000', machine='arm64')
Using venv:  True
Docker: False
Installed: 

PyJWT==2.8.0
adal==1.2.7
applicationinsights==0.11.10
apscheduler==3.10.3
argcomplete==3.1.1
attrs==23.1.0
azure-common==1.1.28
azure-core==1.29.1
azure-cosmos==3.2.0
azure-cosmosdb-nspkg==2.0.2
azure-cosmosdb-table==1.0.6
azure-functions==1.15.0
azure-graphrbac==0.61.1
azure-identity==1.14.0
azure-keyvault==4.2.0
azure-keyvault-certificates==4.7.0
azure-keyvault-keys==4.8.0
azure-keyvault-secrets==4.7.0
azure-mgmt-advisor==9.0.0
azure-mgmt-apimanagement==1.0.0
azure-mgmt-applicationinsights==1.0.0
azure-mgmt-appplatform==8.0.0
azure-mgmt-authorization==1.0.0
azure-mgmt-batch==15.0.0
azure-mgmt-cdn==10.0.0
azure-mgmt-cognitiveservices==11.0.0
azure-mgmt-compute==19.0.0
azure-mgmt-containerinstance==7.0.0
azure-mgmt-containerregistry==8.0.0b1
azure-mgmt-containerservice==15.1.0
azure-mgmt-core==1.4.0
azure-mgmt-cosmosdb==6.4.0
azure-mgmt-costmanagement==1.0.0
azure-mgmt-databricks==1.0.0b1
azure-mgmt-datafactory==1.1.0
azure-mgmt-datalake-nspkg==3.0.1
azure-mgmt-datalake-store==0.5.0
azure-mgmt-dns==8.0.0b1
azure-mgmt-eventgrid==8.0.0
azure-mgmt-eventhub==8.0.0
azure-mgmt-frontdoor==1.1.0
azure-mgmt-hdinsight==7.0.0
azure-mgmt-iothub==1.0.0
azure-mgmt-keyvault==8.0.0
azure-mgmt-logic==9.0.0
azure-mgmt-managementgroups==1.0.0b1
azure-mgmt-monitor==2.0.0
azure-mgmt-msi==1.0.0
azure-mgmt-network==17.1.0
azure-mgmt-nspkg==3.0.2
azure-mgmt-policyinsights==1.0.0
azure-mgmt-rdbms==8.1.0
azure-mgmt-recoveryservices==2.4.0
azure-mgmt-redhatopenshift==1.2.0
azure-mgmt-redis==12.0.0
azure-mgmt-resource==16.1.0
azure-mgmt-resourcegraph==7.0.0
azure-mgmt-search==8.0.0
azure-mgmt-security==1.0.0
azure-mgmt-servicebus==8.2.0
azure-mgmt-servicefabric==1.0.0
azure-mgmt-sql==1.0.0
azure-mgmt-storage==17.1.0
azure-mgmt-subscription==1.0.0
azure-mgmt-trafficmanager==0.51.0
azure-mgmt-web==2.0.0
azure-nspkg==3.0.2
azure-storage-blob==12.17.0
azure-storage-common==2.1.0
azure-storage-file==2.1.0
azure-storage-file-share==12.13.0
azure-storage-queue==12.6.0
boto3==1.28.25
botocore==1.31.25
c7n==0.9.30
certifi==2023.7.22
cffi==1.15.1
charset-normalizer==3.2.0
click==8.1.6
cryptography==41.0.3
distlib==0.3.7
docutils==0.18.1
idna==3.4
importlib-metadata==5.2.0
isodate==0.6.1
jmespath==1.0.1
jsonschema==4.19.0
jsonschema-specifications==2023.7.1
msal==1.23.0
msal-extensions==1.0.0
msrest==0.7.1
msrestazure==0.6.4
netaddr==0.7.20
oauthlib==3.2.2
portalocker==2.7.0
pycparser==2.21
pyjwt==2.8.0
python-dateutil==2.8.2
pytz==2023.3
pyyaml==6.0.1
referencing==0.30.2
requests==2.31.0
requests-oauthlib==1.3.1
rpds-py==0.9.2
s3transfer==0.6.1
six==1.16.0
tabulate==0.9.0
typing-extensions==4.7.1
tzlocal==5.0.1
urllib3==1.26.16
zipp==3.16.2
```


### Policy

```shell
policies:
  - name: c7n-vm-tag-detected-creator-foo
    mode:
          type: azure-periodic
          schedule: '0 */5 * * * *'
          provision-options:
            servicePlan:
              name: 
              location: 
              resourceGroupName: 
            storageAccount: 
              name: 
            identity:
              type: UserAssigned
              id: 
          execution-options:
            output_dir: azure://
    description: |
      Apply c7n-detected-user tag to VMs
    resource: azure.vm
    actions:
      - type: auto-tag-user
        tag: c7n-detected-creator-foo
    filters:
      - type: value
        key: resourceGroup
        value: 
      - type: value
        key: "tag:c7n-detected-creator-foo"
        value: absent
```


### Relevant log/traceback output

_No response_

### Extra information or context

_No response_
output to Azure blob storage doesn't store actual output
### Describe the bug

When a policy is configured to write its output to an Azure blob container, the resultant blob objects contain only a plain text string of the local output location (i.e. `/tmp/tmp<random string>/<filename>.gz`)

### What did you expect to happen?

I expected the blob objects to contain a gzipped version of the output file corresponding to the blob name. i.e.: `resources.json.gz` should contain a gzipped file in JSON format describing the resources retrieved by that policy run.

### Cloud Provider

Microsoft Azure

### Cloud Custodian version and dependency information

```shell
Please copy/paste the following info along with any bug reports:

Custodian:   0.9.30
Python:      3.11.2 (v3.11.2:878ead1ac1, Feb  7 2023, 10:02:41) [Clang 13.0.0 (clang-1300.0.29.30)]
Platform:    posix.uname_result(sysname='Darwin', nodename='F9YPT71GDJ', release='22.6.0', version='Darwin Kernel Version 22.6.0: Wed Jul  5 22:22:05 PDT 2023; root:xnu-8796.141.3~6/RELEASE_ARM64_T6000', machine='arm64')
Using venv:  True
Docker: False
Installed: 

PyJWT==2.8.0
adal==1.2.7
applicationinsights==0.11.10
apscheduler==3.10.3
argcomplete==3.1.1
attrs==23.1.0
azure-common==1.1.28
azure-core==1.29.1
azure-cosmos==3.2.0
azure-cosmosdb-nspkg==2.0.2
azure-cosmosdb-table==1.0.6
azure-functions==1.15.0
azure-graphrbac==0.61.1
azure-identity==1.14.0
azure-keyvault==4.2.0
azure-keyvault-certificates==4.7.0
azure-keyvault-keys==4.8.0
azure-keyvault-secrets==4.7.0
azure-mgmt-advisor==9.0.0
azure-mgmt-apimanagement==1.0.0
azure-mgmt-applicationinsights==1.0.0
azure-mgmt-appplatform==8.0.0
azure-mgmt-authorization==1.0.0
azure-mgmt-batch==15.0.0
azure-mgmt-cdn==10.0.0
azure-mgmt-cognitiveservices==11.0.0
azure-mgmt-compute==19.0.0
azure-mgmt-containerinstance==7.0.0
azure-mgmt-containerregistry==8.0.0b1
azure-mgmt-containerservice==15.1.0
azure-mgmt-core==1.4.0
azure-mgmt-cosmosdb==6.4.0
azure-mgmt-costmanagement==1.0.0
azure-mgmt-databricks==1.0.0b1
azure-mgmt-datafactory==1.1.0
azure-mgmt-datalake-nspkg==3.0.1
azure-mgmt-datalake-store==0.5.0
azure-mgmt-dns==8.0.0b1
azure-mgmt-eventgrid==8.0.0
azure-mgmt-eventhub==8.0.0
azure-mgmt-frontdoor==1.1.0
azure-mgmt-hdinsight==7.0.0
azure-mgmt-iothub==1.0.0
azure-mgmt-keyvault==8.0.0
azure-mgmt-logic==9.0.0
azure-mgmt-managementgroups==1.0.0b1
azure-mgmt-monitor==2.0.0
azure-mgmt-msi==1.0.0
azure-mgmt-network==17.1.0
azure-mgmt-nspkg==3.0.2
azure-mgmt-policyinsights==1.0.0
azure-mgmt-rdbms==8.1.0
azure-mgmt-recoveryservices==2.4.0
azure-mgmt-redhatopenshift==1.2.0
azure-mgmt-redis==12.0.0
azure-mgmt-resource==16.1.0
azure-mgmt-resourcegraph==7.0.0
azure-mgmt-search==8.0.0
azure-mgmt-security==1.0.0
azure-mgmt-servicebus==8.2.0
azure-mgmt-servicefabric==1.0.0
azure-mgmt-sql==1.0.0
azure-mgmt-storage==17.1.0
azure-mgmt-subscription==1.0.0
azure-mgmt-trafficmanager==0.51.0
azure-mgmt-web==2.0.0
azure-nspkg==3.0.2
azure-storage-blob==12.17.0
azure-storage-common==2.1.0
azure-storage-file==2.1.0
azure-storage-file-share==12.13.0
azure-storage-queue==12.6.0
boto3==1.28.25
botocore==1.31.25
c7n==0.9.30
certifi==2023.7.22
cffi==1.15.1
charset-normalizer==3.2.0
click==8.1.6
cryptography==41.0.3
distlib==0.3.7
docutils==0.18.1
idna==3.4
importlib-metadata==5.2.0
isodate==0.6.1
jmespath==1.0.1
jsonschema==4.19.0
jsonschema-specifications==2023.7.1
msal==1.23.0
msal-extensions==1.0.0
msrest==0.7.1
msrestazure==0.6.4
netaddr==0.7.20
oauthlib==3.2.2
portalocker==2.7.0
pycparser==2.21
pyjwt==2.8.0
python-dateutil==2.8.2
pytz==2023.3
pyyaml==6.0.1
referencing==0.30.2
requests==2.31.0
requests-oauthlib==1.3.1
rpds-py==0.9.2
s3transfer==0.6.1
six==1.16.0
tabulate==0.9.0
typing-extensions==4.7.1
tzlocal==5.0.1
urllib3==1.26.16
zipp==3.16.2
```


### Policy

```shell
policies:
  - name: c7n-vm-tag-detected-creator-foo
    mode:
          type: azure-periodic
          schedule: '0 */5 * * * *'
          provision-options:
            servicePlan:
              name: 
              location: 
              resourceGroupName: 
            storageAccount: 
              name: 
            identity:
              type: UserAssigned
              id: 
          execution-options:
            output_dir: azure://
    description: |
      Apply c7n-detected-user tag to VMs
    resource: azure.vm
    actions:
      - type: auto-tag-user
        tag: c7n-detected-creator-foo
    filters:
      - type: value
        key: resourceGroup
        value: 
      - type: value
        key: "tag:c7n-detected-creator-foo"
        value: absent
```


### Relevant log/traceback output

_No response_

### Extra information or context

_No response_


Discussion:

Resolving patch:
diff --git a/tools/c7n_azure/c7n_azure/storage_utils.py b/tools/c7n_azure/c7n_azure/storage_utils.py
--- a/tools/c7n_azure/c7n_azure/storage_utils.py
+++ b/tools/c7n_azure/c7n_azure/storage_utils.py
@@ -11,9 +11,10 @@
 
 class OldBlobServiceClient(BlobServiceClient):
 
-    def create_blob_from_path(self, container_name, blob_name, content):
+    def create_blob_from_path(self, container_name, blob_name, path):
         client = self.get_blob_client(container_name, blob_name)
-        client.upload_blob(content, overwrite=True)
+        with open(path, "rb") as data:
+            client.upload_blob(data, overwrite=True)
 
     def get_blob_to_bytes(self, container_name, blob_name):
         client = self.get_blob_client(container_name, blob_name)


Test patch: