I am using the azure sdk inside an azure function ...
# azure
b
I am using the azure sdk inside an azure function to upload a blob to a container and when trying to run pulumi up I receive the following message. Does anyone know how to solve this problem?
g
Can you share your code?
b
Copy code
const getStorageFunction = (opts) => new Promise((resolve) => {
  const account = storageAccount.name;
  const defaultAzureCredential = new DefaultAzureCredential();
  const blobServiceClient = new BlobServiceClient(
    `https://${account}.<http://blob.core.windows.net|blob.core.windows.net>`,
    defaultAzureCredential,
  );

  const containerClient = blobServiceClient.getContainerClient(container);
  const content = 'Hello world!';
  const blobName = `${new Date().getTime()}.txt`;
  const blockBlobClient = containerClient.getBlockBlobClient(blobName);
  blockBlobClient.upload(content, content.length)
    .then(() => resolve({
      status: 200,
      headers: {
        'content-type': 'text/plain',
      },
      body: 'Success',
    }))
    .catch((e) => resolve({
      status: 200,
      headers: {
        'content-type': 'text/plain',
      },
      body: `Error: ${e.message}`,
    }));
});
The azure function is triggered by an HTTP request
g
Can you share the Pulumi code that's defining the function too?
b
Copy code
const handler = async (context, req) => {
  return getStorageFunction({ container: '' /*TODO*/ });
};

const endpoint = new azure.appservice.HttpEventSubscription('InfraEndpoint', {
  resourceGroup,
  callback: handler,
  appSettings: {
    APPINSIGHTS_INSTRUMENTATIONKEY: insights.instrumentationKey,
  },
});
The problem goes away if I remove the azure sdk code
t
I'm confused. Where is the Pulumi code?
t
@tall-needle-56640
azure.appservice.HttpEventSubscription
is a Pulumi resource
t
Oh... I couldn't find it in either of the provider docs or by searching on the Pulumi site.
t
I guess our docs aren’t great here… Here is probably the best source https://www.pulumi.com/blog/ten-pearls-with-azure-functions-in-pulumi/
👍 1
b
The error was caused by using named imports and fixed by only using default imports. I have no idea why