GithubHelp home page GithubHelp logo

storage-blobs-php-quickstart's Introduction

services platforms author
storage
php
roygara

Transfer objects to and from Azure Blob storage using PHP

This repository contains a simple sample project to help you getting started with Azure storage using .NET as the development language.

Prerequisites

To complete this tutorial:

To complete this quickstart:

If you don't have an Azure subscription, create a free account before you begin.

Create a storage account using the Azure portal

First, create a new general-purpose storage account to use for this quickstart.

  1. Go to the Azure portal and log in using your Azure account.
  2. Enter a unique name for your storage account. Keep these rules in mind for naming your storage account:
    • The name must be between 3 and 24 characters in length.
    • The name may contain numbers and lowercase letters only.
  3. Make sure that the following default values are set:
    • Deployment model is set to Resource manager.
    • Account kind is set to General purpose.
    • Performance is set to Standard.
    • Replication is set to Locally Redundant storage (LRS).
  4. Select your subscription.
  5. For Resource group, create a new one and give it a unique name.
  6. Select the Location to use for your storage account.
  7. Check Pin to dashboard and click Create to create your storage account.

After your storage account is created, it is pinned to the dashboard. Click on it to open it. Under Settings, click Access keys. Select the primary key and copy the associated Connection string to the clipboard, then paste it into a text editor for later use.

Put the connection string in an environment variable

This solution requires a connection string be stored in an environment variable securely on the machine running the sample. Follow one of the examples below depending on your Operating System to create the environment variable. If using windows close out of your open IDE or shell and restart it to be able to read the environment variable.

Linux

export storageconnectionstring="<yourconnectionstring>"

Windows

setx storageconnectionstring "<yourconnectionstring>"

At this point, you can run this application. It creates its own file to upload and download, and then cleans up after itself by deleting everything at the end.

More information

The Azure storage documentation includes a rich set of tutorials and conceptual articles, which serve as a good complement to the samples.

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact [email protected] with any additional questions or comments.

storage-blobs-php-quickstart's People

Contributors

microsoftopensource avatar msftgits avatar roygara avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

storage-blobs-php-quickstart's Issues

File uploaded to Azure is empty

Please provide us with the following information:

This issue is for a: (mark with an x)

- [x] bug report -> please search issues before submitting
- [ ] feature request
- [ ] documentation issue or request
- [ ] regression (a behavior that used to work and stopped in a new release)

Minimal steps to reproduce

run the application/file phpQS.php

Any log messages given by the failure

none

Expected/desired behavior

the file HelloWorld.txt uploaded to Azure Blob storage should have the text "Hello Azure!" in it, but it is empty.

OS and Version?

Windows 7, 8 or 10. Linux (which distribution). macOS (Yosemite? El Capitan? Sierra?)

Windows 10 Professional

Versions

Mention any other details that might be useful

On line 84 in phpQS.php the call to open the file in "write" mode will essentially truncate the file contents (http://php.net/manual/en/function.fopen.php ):
$myfile = fopen($fileToUpload, "w") or die("Unable to open file!");
Thus when the file is subsequently uploaded to Azure it will be empty.
Since the intention is just to see if the file exists/can be read, the fix would be to use the "read" flag on line 84:
$myfile = fopen($fileToUpload, "r") or die("Unable to open file!");


Thanks! We'll be in touch soon.

Undefined variable: containerName

Please provide us with the following information:

This issue is for a: (mark with an x)

- [x] bug report -> please search issues before submitting
- [ ] feature request
- [ ] documentation issue or request
- [ ] regression (a behavior that used to work and stopped in a new release)

Minimal steps to reproduce

click on the button "Press to clean up all resources created by this sample"

Any log messages given by the failure

"( ! ) Notice: Undefined variable: containerName in /var/www/html/storage-blobs-php-quickstart/phpQS.php on line 159 "

Expected/desired behavior

no error message

OS and Version?

Windows 7, 8 or 10. Linux (which distribution). macOS (Yosemite? El Capitan? Sierra?)

Windows 10 professional

Versions

Mention any other details that might be useful

the variable $containerName is not defined after the button is pressed
A potential solution would be to add
$containerName = $_GET["containerName"];
around line 145 or so in phpQS.php


Thanks! We'll be in touch soon.

huriatiblob

Please provide us with the following information:

This issue is for a: (mark with an x)

- [ ] bug report -> please search issues before submitting
- [ ] feature request
- [ ] documentation issue or request
- [ ] regression (a behavior that used to work and stopped in a new release)

Minimal steps to reproduce

Any log messages given by the failure

Expected/desired behavior

OS and Version?

Windows 7, 8 or 10. Linux (which distribution). macOS (Yosemite? El Capitan? Sierra?)

Versions

Mention any other details that might be useful


Thanks! We'll be in touch soon.

Uncaught exception 'RuntimeException' with message 'The provided account key '' is not a valid base64 string. It has to pass the check 'base64_decode(, true)'.'

Fatal error: Uncaught exception 'RuntimeException' with message 'The provided account key '' is not a valid base64 string. It has to pass the check 'base64_decode(, true)'.' in D:\home\site\wwwroot\vendor\microsoft\azure-storage-common\src\Common\Internal\StorageServiceSettings.php:112 Stack trace: #0 D:\home\site\wwwroot\vendor\microsoft\azure-storage-common\src\Common\Internal\ServiceSettings.php(133): MicrosoftAzure\Storage\Common\Internal\StorageServiceSettings::MicrosoftAzure\Storage\Common\Internal{closure}('') #1 D:\home\site\wwwroot\vendor\microsoft\azure-storage-common\src\Common\Internal\ServiceSettings.php(273): MicrosoftAzure\Storage\Common\Internal\StorageServiceSettings::MicrosoftAzure\Storage\Common\Internal{closure}(Array) #2 D:\home\site\wwwroot\vendor\microsoft\azure-storage-common\src\Common\Internal\StorageServiceSettings.php(401): MicrosoftAzure\Storage\Common\Internal\ServiceSettings::matchedSpecification(Array, Object(Closure), Object(Closure)) #3 D:\home\site\wwwroot\vendor\micr in D:\home\site\wwwroot\vendor\microsoft\azure-storage-common\src\Common\Internal\StorageServiceSettings.php on line 112

can I help this error message why the account_key is invalid with base64_decode

[Action Needed] This repo is inactive

This GitHub repository has been identified as a candidate for archival

This repository has had no activity for more than 2 years. Long periods of inactivity present security and code hygiene risks. Archiving will not prevent users from viewing or forking the code. A banner will appear on the repository alerting users that the repository is archived.

Please see https://aka.ms/sunsetting-faq to learn more about this process.

Action

✍️

❗**If this repository is still actively maintained, please simply close this issue. Closing an issue on a repository is considered activity and the repository will not be archived.🔒

If you take no action, this repository is still inactive 30 days from today it will be automatically archived..

Need more help? 🖐️

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.